resources

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package resources maps Terraform resource types to per-product Mappers.

Adding support for a new resource type = writing one file that implements Mapper.Extract (plan -> PriceRequest) and Mapper.Parse (raw API response -> CostComponents).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSDBInstance

type AWSDBInstance struct{}

AWSDBInstance handles `aws_db_instance`.

func (AWSDBInstance) Extract

func (AWSDBInstance) Parse

type AWSDocDBInstance

type AWSDocDBInstance struct{}

AWSDocDBInstance handles `aws_docdb_cluster_instance`.

func (AWSDocDBInstance) Extract

func (AWSDocDBInstance) Parse

type AWSDynamoDBTable

type AWSDynamoDBTable struct{}

AWSDynamoDBTable handles `aws_dynamodb_table` (provisioned mode only).

func (AWSDynamoDBTable) Extract

func (AWSDynamoDBTable) Parse

type AWSEBSVolume

type AWSEBSVolume struct{}

AWSEBSVolume handles `aws_ebs_volume`.

func (AWSEBSVolume) Extract

func (AWSEBSVolume) Parse

type AWSEKSCluster

type AWSEKSCluster struct{}

AWSEKSCluster handles `aws_eks_cluster` (control plane only).

func (AWSEKSCluster) Extract

func (AWSEKSCluster) Parse

type AWSELB

type AWSELB struct{}

AWSELB handles `aws_elb` (Classic Load Balancer).

func (AWSELB) Extract

func (AWSELB) Parse

func (AWSELB) Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)

type AWSElastiCacheCluster

type AWSElastiCacheCluster struct{}

AWSElastiCacheCluster handles `aws_elasticache_cluster`.

func (AWSElastiCacheCluster) Extract

func (AWSElastiCacheCluster) Parse

type AWSInstance

type AWSInstance struct{}

AWSInstance handles `aws_instance`.

func (AWSInstance) Extract

func (AWSInstance) Parse

type AWSLB

type AWSLB struct{}

AWSLB handles `aws_lb` (Application / Network / Gateway load balancers).

func (AWSLB) Extract

func (AWSLB) Parse

func (AWSLB) Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)

type AWSMQBroker

type AWSMQBroker struct{}

AWSMQBroker handles `aws_mq_broker`.

func (AWSMQBroker) Extract

func (AWSMQBroker) Parse

type AWSMSKCluster

type AWSMSKCluster struct{}

AWSMSKCluster handles `aws_msk_cluster` (provisioned).

func (AWSMSKCluster) Extract

func (AWSMSKCluster) Parse

type AWSMemoryDBCluster

type AWSMemoryDBCluster struct{}

AWSMemoryDBCluster handles `aws_memorydb_cluster`. Total nodes = num_shards * (1 + num_replicas_per_shard).

func (AWSMemoryDBCluster) Extract

func (AWSMemoryDBCluster) Parse

type AWSNATGateway

type AWSNATGateway struct{}

AWSNATGateway handles `aws_nat_gateway`.

func (AWSNATGateway) Extract

func (AWSNATGateway) Parse

type AWSNeptuneInstance

type AWSNeptuneInstance struct{}

AWSNeptuneInstance handles `aws_neptune_cluster_instance`.

func (AWSNeptuneInstance) Extract

func (AWSNeptuneInstance) Parse

type AWSOpenSearchDomain

type AWSOpenSearchDomain struct{}

AWSOpenSearchDomain handles `aws_opensearch_domain` and `aws_elasticsearch_domain` (identical schema for our purposes).

func (AWSOpenSearchDomain) Extract

func (AWSOpenSearchDomain) Parse

type AWSRDSClusterInstance

type AWSRDSClusterInstance struct{}

AWSRDSClusterInstance handles `aws_rds_cluster_instance` (Aurora members).

func (AWSRDSClusterInstance) Extract

func (AWSRDSClusterInstance) Parse

type AWSRedshiftCluster

type AWSRedshiftCluster struct{}

AWSRedshiftCluster handles `aws_redshift_cluster`.

func (AWSRedshiftCluster) Extract

func (AWSRedshiftCluster) Parse

type AlibabaDisk added in v0.3.0

type AlibabaDisk struct{}

AlibabaDisk handles `alicloud_disk` (cloud disk / EBS equivalent).

func (AlibabaDisk) Extract added in v0.3.0

func (AlibabaDisk) Parse added in v0.3.0

type AlibabaECS added in v0.3.0

type AlibabaECS struct{}

AlibabaECS handles `alicloud_instance` (ECS).

Priced via Alibaba Cloud BSS DescribePrice with ProductCode "ecs". ModuleList: InstanceType, SystemDisk (optional).

func (AlibabaECS) Extract added in v0.3.0

func (AlibabaECS) Parse added in v0.3.0

type AlibabaEIP added in v0.3.0

type AlibabaEIP struct{}

AlibabaEIP handles `alicloud_eip` (elastic IP).

func (AlibabaEIP) Extract added in v0.3.0

func (AlibabaEIP) Parse added in v0.3.0

type AlibabaMongoDB added in v0.3.0

type AlibabaMongoDB struct{}

AlibabaMongoDB handles `alicloud_mongodb_instance` (ApsaraDB for MongoDB).

func (AlibabaMongoDB) Extract added in v0.3.0

func (AlibabaMongoDB) Parse added in v0.3.0

type AlibabaNAT added in v0.3.0

type AlibabaNAT struct{}

AlibabaNAT handles `alicloud_nat_gateway`.

Priced via Alibaba Cloud BSS DescribePrice with ProductCode "natgateway". ModuleList: Specification.

func (AlibabaNAT) Extract added in v0.3.0

func (AlibabaNAT) Parse added in v0.3.0

type AlibabaRDS added in v0.3.0

type AlibabaRDS struct{}

AlibabaRDS handles `alicloud_db_instance` (RDS).

func (AlibabaRDS) Extract added in v0.3.0

func (AlibabaRDS) Parse added in v0.3.0

type AlibabaRedis added in v0.3.0

type AlibabaRedis struct{}

AlibabaRedis handles `alicloud_kvstore_instance` (ApsaraDB for Redis / Tair).

func (AlibabaRedis) Extract added in v0.3.0

func (AlibabaRedis) Parse added in v0.3.0

type AlibabaSLB added in v0.3.0

type AlibabaSLB struct{}

AlibabaSLB handles `alicloud_slb_load_balancer` (Server Load Balancer, CLB/ALB).

func (AlibabaSLB) Extract added in v0.3.0

func (AlibabaSLB) Parse added in v0.3.0

type AlibabaVPN added in v0.3.0

type AlibabaVPN struct{}

AlibabaVPN handles `alicloud_vpn_gateway`.

Priced via Alibaba Cloud BSS DescribePrice with ProductCode "vpn". ModuleList: Bandwidth.

func (AlibabaVPN) Extract added in v0.3.0

func (AlibabaVPN) Parse added in v0.3.0

type CBSStorage

type CBSStorage struct{}

CBSStorage handles `tencentcloud_cbs_storage`.

Reference: https://cloud.tencent.com/document/api/362/16315 (InquiryPriceCreateDisks → Response.DiskPrice.OriginalPrice / DiscountPrice)

func (CBSStorage) Extract

func (CBSStorage) Parse

func (CBSStorage) Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)

type CLBInstance

type CLBInstance struct{}

CLBInstance handles `tencentcloud_clb_instance`.

Reference: https://cloud.tencent.com/document/api/214/41708 (InquiryPriceCreateLoadBalancer → Response.Price)

CLB pricing has two dimensions:

  • Instance fee (LB itself, per hour or fixed monthly for prepaid)
  • Traffic/bandwidth fee (depends on internet_charge_type)

func (CLBInstance) Extract

func (CLBInstance) Parse

type CVMInstance

type CVMInstance struct{}

CVMInstance handles `tencentcloud_instance`.

Reference: https://cloud.tencent.com/document/api/213/15726 (InquiryPriceRunInstances → Response.Price.InstancePrice + BandwidthPrice)

func (CVMInstance) Extract

func (CVMInstance) Parse

type CloudHSMInstance

type CloudHSMInstance struct{}

CloudHSMInstance handles `tencentcloud_cloudhsm_instance` (Cloud HSM / 云加密机 VSM).

Pricing API (cloudhsm): InquiryPriceBuyVsm (Inquiry, with 'y'). Docs: https://cloud.tencent.com/document/api/1300/60498

The request takes GoodsNum/PayMode/TimeSpan/TimeUnit. cloudhsm supports a prepaid mode (PayMode=1) billed by month; cloudtab always prices a single month (TimeSpan=1, TimeUnit="m") so the returned total is the monthly run-rate. Response.{OriginalCost,TotalCost} are float64 in 元 (TotalCost is the discounted/payable amount, OriginalCost the list price). Currency is echoed from the request (default CNY).

func (CloudHSMInstance) Extract

func (CloudHSMInstance) Parse

type CynosDBCluster

type CynosDBCluster struct{}

CynosDBCluster handles `tencentcloud_cynosdb_cluster` (TDSQL-C).

Pricing API (cynosdb): InquirePriceCreate (SDK spells it "InquirePrice", without the 'y'). Docs: https://cloud.tencent.com/document/api/1003/48086

Terraform provider fields commonly seen:

  • available_zone, cpu, memory (GB), storage_limit (GB), charge_type (PREPAID | POSTPAID), prepaid_period, instance_count

Response has two TradePrice blocks — InstancePrice and StoragePrice — each in 分 (int64). PREPAID uses TotalPriceDiscount (period total); POSTPAID uses UnitPriceDiscount (hourly). We sum instance + storage.

func (CynosDBCluster) Extract

func (CynosDBCluster) Parse

type DCDBInstance

type DCDBInstance struct{}

DCDBInstance handles `tencentcloud_dcdb_instance` (TDSQL MySQL, distributed).

Pricing API (dcdb): DescribeDCDBPrice. Docs: https://cloud.tencent.com/document/api/557/16135

We request AmountUnit="pent" so Response.{OriginalPrice,Price} come back as int64 分 (value/100 = 元). Paymode is the lowercase "prepaid"/"postpaid". For PREPAID the value is the total for the requested Period; for POSTPAID it is an hourly rate. cloudtab always prices a single month (Period=1).

func (DCDBInstance) Extract

func (DCDBInstance) Parse

type DomainRegistration

type DomainRegistration struct{}

DomainRegistration handles `tencentcloud_domain_registration`.

Pricing API (domain): DescribeDomainPriceList (Describe, not Inquiry). Docs: https://cloud.tencent.com/document/api/242/48941

Domain pricing is fundamentally different from instance products: the API returns a PriceList of {Tld, Year, Operation, Price, RealPrice} tuples. There is no region, no charge type, and prices are one-off yearly fees, not monthly instance run-rates. We query the "new" (first-purchase) price for 1 year for the resource's TLD, then divide by 12 to express a comparable monthly figure.

IMPORTANT — pricing unit: the SDK types Price/RealPrice as uint64 but the API docs and struct comments (域名原价/域名现价) do NOT state a unit. Empirically this endpoint returns whole-yuan (元) integers (e.g. 55 for a ¥55/year .com), NOT cents. We therefore treat the value as 元 directly. If a future SDK/API revision switches to 分, change domainPriceUnitDivisor to 100.0.

func (DomainRegistration) Extract

func (DomainRegistration) Parse

type ECMInstance

type ECMInstance struct{}

ECMInstance handles `tencentcloud_ecm_instance` (Edge Computing Machine).

Pricing API (ecm): DescribePriceRunInstance. Docs: https://cloud.tencent.com/document/api/1108/42030

InstanceChargeType is an int enum: 0 = resource-postpaid, 1 = hourly-postpaid, 2 = monthly-postpaid. ECM has no PREPAID mode. Response.InstancePrice. {OriginalPrice,DiscountPrice} are uint64 in 分 (value/100 = 元); the value is an hourly rate for the hourly charge types.

func (ECMInstance) Extract

func (ECMInstance) Parse

type EIP

type EIP struct{}

EIP handles `tencentcloud_eip`.

Note: Tencent Cloud's VPC SDK does not expose an InquiryPrice* API for EIP. Real EIP cost depends on the charge type and, for traffic-based billing, on actual monthly traffic which is not present in a Terraform plan. We therefore return a zero-cost placeholder line with a descriptive note and route it through the StaticMapper path so it never calls the pricing engine.

func (EIP) Estimate

func (EIP) Extract

func (EIP) Parse

func (EIP) Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)

type GAAPProxy

type GAAPProxy struct{}

GAAPProxy handles `tencentcloud_gaap_proxy` (Global Application Acceleration).

Pricing API (gaap): InquiryPriceCreateProxy. Docs: https://cloud.tencent.com/document/api/608/37569

GAAP quotes a DAILY proxy price. Response.{ProxyDailyPrice, DiscountProxyDailyPrice} are float64 in 元/day. We convert to a monthly run-rate with the shared 730h month (≈30.4 days). BillingType is an int: 0 = by bandwidth, 1 = by flow.

func (GAAPProxy) Extract

func (GAAPProxy) Parse

func (GAAPProxy) Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)

type HuaweiCCE added in v0.3.0

type HuaweiCCE struct{}

HuaweiCCE handles `huaweicloud_cce_cluster` (CCE).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiCCE) Extract added in v0.3.0

func (HuaweiCCE) Parse added in v0.3.0

type HuaweiDCS added in v0.3.0

type HuaweiDCS struct{}

HuaweiDCS handles `huaweicloud_dcs_instance` (DCS).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiDCS) Extract added in v0.3.0

func (HuaweiDCS) Parse added in v0.3.0

type HuaweiDDS added in v0.3.0

type HuaweiDDS struct{}

HuaweiDDS handles `huaweicloud_dds_instance` (DDS).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiDDS) Extract added in v0.3.0

func (HuaweiDDS) Parse added in v0.3.0

type HuaweiECS added in v0.3.0

type HuaweiECS struct{}

HuaweiECS handles `huaweicloud_compute_instance` (ECS).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiECS) Extract added in v0.3.0

func (HuaweiECS) Parse added in v0.3.0

type HuaweiEIP added in v0.3.0

type HuaweiEIP struct{}

HuaweiEIP handles `huaweicloud_vpc_eip` (elastic IP / bandwidth).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiEIP) Extract added in v0.3.0

func (HuaweiEIP) Parse added in v0.3.0

type HuaweiELB added in v0.3.0

type HuaweiELB struct{}

HuaweiELB handles `huaweicloud_elb_loadbalancer` (ELB).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiELB) Extract added in v0.3.0

func (HuaweiELB) Parse added in v0.3.0

type HuaweiEVS added in v0.3.0

type HuaweiEVS struct{}

HuaweiEVS handles `huaweicloud_evs_volume` (EVS disk).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiEVS) Extract added in v0.3.0

func (HuaweiEVS) Parse added in v0.3.0

type HuaweiNAT added in v0.3.0

type HuaweiNAT struct{}

HuaweiNAT handles `huaweicloud_nat_gateway` (NAT Gateway).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiNAT) Extract added in v0.3.0

func (HuaweiNAT) Parse added in v0.3.0

type HuaweiRDS added in v0.3.0

type HuaweiRDS struct{}

HuaweiRDS handles `huaweicloud_rds_instance` (RDS).

Priced via Huawei Cloud BSS ListOnDemandResourceRatings.

func (HuaweiRDS) Extract added in v0.3.0

func (HuaweiRDS) Parse added in v0.3.0

type LighthouseInstance

type LighthouseInstance struct{}

LighthouseInstance handles `tencentcloud_lighthouse_instance`.

Pricing API (lighthouse): InquirePriceCreateInstances (SDK spells it "InquirePrice", without the 'y'). Docs: https://cloud.tencent.com/document/api/1207/47576

Lighthouse is a prepaid, bundle-priced product: you buy a BundleId for a number of months. Response.Price.InstancePrice.{OriginalPrice,DiscountPrice} is in 元 and is the total for the requested Period. cloudtab always prices a single month (Period=1) so the returned price is the monthly run-rate.

func (LighthouseInstance) Extract

func (LighthouseInstance) Parse

type Mapper

type Mapper interface {
	Extract(r parser.PlannedResource) (pricing.PriceRequest, error)
	Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)
}

Mapper is the contract every resource type implements.

type MariaDBInstance

type MariaDBInstance struct{}

MariaDBInstance handles `tencentcloud_mariadb_instance`.

Pricing API (mariadb): DescribePrice. Docs: https://cloud.tencent.com/document/api/237/16177

Terraform provider fields commonly seen:

  • zones (first used as Zone), node_count, memory (GB), storage (GB), period (months), instance_charge_type / charge_type

Response.{Price,OriginalPrice} are int64 in 分 (cents). We request AmountUnit="pent" for an explicit unit and divide by 100 to get 元. The returned figure is the total for the requested Period, so PREPAID is a period total and POSTPAID is an hourly rate.

func (MariaDBInstance) Extract

func (MariaDBInstance) Parse

type MongoDBInstance

type MongoDBInstance struct{}

MongoDBInstance handles `tencentcloud_mongodb_instance`.

Pricing API (mongodb): InquirePriceCreateDBInstances (SDK spells it "InquirePrice", without the 'y'). Docs: https://cloud.tencent.com/document/api/240/38571

Terraform provider fields commonly seen:

  • available_zone, memory (GB), volume (GB), engine_version, machine_type, charge_type, prepaid_period, node_num

Response.Price.{UnitPrice,OriginalPrice,DiscountPrice} is in 元. There is no ChargeUnit field: PREPAID prices are a monthly total, POSTPAID an hourly rate, decided from the charge type in the request.

func (MongoDBInstance) Extract

func (MongoDBInstance) Parse

type MySQLInstance

type MySQLInstance struct{}

MySQLInstance handles `tencentcloud_mysql_instance`.

Pricing API (cdb): DescribeDBPrice. Docs: https://cloud.tencent.com/document/api/236/15866

Terraform provider fields commonly seen: - availability_zone, mem_size, volume_size, charge_type, prepaid_period - cpu, instance_role, device_type

We normalize charge_type to cdb.PayType: - PREPAID -> PRE_PAID - POSTPAID -> HOUR_PAID

Design decision — hourly → monthly conversion: Unlike CVM/CBS/CLB which return InquiryPrice* responses with a ChargeUnit field (handled by monthlyFromPrice), the CDB DescribeDBPrice response does NOT include a ChargeUnit. The Price field is always in 元/小时 for HOUR_PAID and 元/月 for PRE_PAID. Since we cannot use monthlyFromPrice here (no ChargeUnit), we multiply by hoursPerMonth (=730) directly for POSTPAID instances. This is intentional and matches Tencent Cloud console behavior.

func (MySQLInstance) Extract

func (MySQLInstance) Parse

type PostgreSQLInstance

type PostgreSQLInstance struct{}

PostgreSQLInstance handles `tencentcloud_postgresql_instance`.

Pricing API (postgres): InquiryPriceCreateDBInstances. Docs: https://cloud.tencent.com/document/api/409/16777

Terraform provider fields commonly seen: - availability_zone, spec_code, storage, instance_charge_type, prepaid_period - cpu, memory

func (PostgreSQLInstance) Extract

func (PostgreSQLInstance) Parse

type RedisInstance

type RedisInstance struct{}

RedisInstance handles `tencentcloud_redis_instance`.

Pricing API (redis): InquiryPriceCreateInstance. Docs: https://cloud.tencent.com/document/api/239/41159

Terraform provider fields commonly seen: - availability_zone, type_id, mem_size, charge_type, prepaid_period - redis_shard_num, redis_replicas_num, product_version

BillingMode mapping: - POSTPAID -> 0 (pay-as-you-go, treated as hourly for monthly estimate) - PREPAID -> 1 (fixed period price)

func (RedisInstance) Extract

func (RedisInstance) Parse

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns a shared Registry pre-loaded with all supported resource types. It is safe for concurrent use.

func (*Registry) Lookup

func (r *Registry) Lookup(tfType string) (Mapper, bool)

func (*Registry) Register

func (r *Registry) Register(tfType string, m Mapper)

type SQLServerInstance

type SQLServerInstance struct{}

SQLServerInstance handles `tencentcloud_sqlserver_instance`.

Pricing API (sqlserver): InquiryPriceCreateDBInstances. Docs: https://cloud.tencent.com/document/api/238/19992

Response.{OriginalPrice,Price} are int64 in 分 (value/100 = 元). For PREPAID the value is the total for the requested Period; for POSTPAID it is an hourly rate. cloudtab always prices a single month (Period=1) so PREPAID == monthly.

func (SQLServerInstance) Extract

func (SQLServerInstance) Parse

type StaticMapper

type StaticMapper interface {
	Mapper
	Estimate(r parser.PlannedResource) ([]output.CostComponent, error)
}

StaticMapper is an optional extension for resources whose price cannot be fetched from a Tencent InquiryPrice* API. When a Mapper implements this interface, priceReport uses Estimate directly and skips the pricing engine.

type VPNGateway

type VPNGateway struct{}

VPNGateway handles `tencentcloud_vpn_gateway`.

Pricing API (vpc): InquiryPriceCreateVpnGateway. Docs: https://cloud.tencent.com/document/api/215/17517

Terraform provider fields commonly seen:

  • bandwidth (Mbps), charge_type (PREPAID | POSTPAID_BY_HOUR), prepaid_period, type (IPSEC | SSL), max_connection (SSL only)

Response.Price.InstancePrice.{UnitPrice,DiscountPrice,ChargeUnit} is in 元.

func (VPNGateway) Extract

func (VPNGateway) Parse

func (VPNGateway) Parse(req pricing.PriceRequest, raw []byte) ([]output.CostComponent, error)

type YunjingLicense

type YunjingLicense struct{}

YunjingLicense handles `tencentcloud_cwp_license_order` (Cloud Workload Protection / 主机安全 professional-version license).

Pricing API (yunjing): InquiryPriceOpenProVersionPrepaid (Inquiry, with 'y'). Docs: https://cloud.tencent.com/document/api/296/19836

The professional version is a prepaid, per-machine license. The request takes a ChargePrepaid{Period,RenewFlag} block plus a Machines list; cloudtab always prices a single month (Period=1) so the returned total is the monthly run-rate. Response.{OriginalPrice,DiscountPrice} are float64 in 元 for the whole requested period (no per-instance currency field; CNY is implied).

func (YunjingLicense) Extract

func (YunjingLicense) Parse

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL