Documentation
¶
Overview ¶
Package parser loads Terraform plan JSON into a normalized resource list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProviderForType ¶
ProviderForType maps a Terraform resource type to the pricing provider that serves it, based on the type's provider prefix.
Types ¶
type Plan ¶
type Plan struct {
FormatVersion string `json:"format_version"`
Resources []PlannedResource `json:"-"`
}
func LoadPlanInventoryJSON ¶ added in v0.3.20
LoadPlanInventoryJSON parses the final managed-resource inventory from planned_values.root_module. Older plan JSON without that root falls back to LoadPlanJSON's create/update resource_changes behavior.
func LoadPlanJSON ¶
LoadPlanJSON parses `terraform show -json <plan>` output. Only "create" and "update" actions contribute to cost; "delete" resources are handled in diff mode.
type PlannedResource ¶
type PlannedResource struct {
Address string `json:"address"`
Type string `json:"type"` // e.g. "tencentcloud_instance"
Name string `json:"name"`
After map[string]interface{} `json:"after"` // resource_changes[].change.after
Region string `json:"region,omitempty"`
}
PlannedResource is one row we hand to the pricing engine. It intentionally keeps the raw attribute map so per-type mappers can pull what they need (instance_type, data_disks, charge_type, etc.).
type UsageData ¶ added in v0.4.0
type UsageData struct {
Version int
Legacy UsageOverrides
Resources map[string]UsageResource
}
UsageData contains either legacy overrides or typed versioned usage.
func LoadUsageFile ¶ added in v0.4.0
LoadUsageFile reads either legacy unversioned overrides or strict version 1 usage.
func (UsageData) IsVersioned ¶ added in v0.4.0
type UsageOverrides ¶
UsageOverrides maps resource address -> arbitrary usage key/value pairs. Unknown fields are preserved and consumed by mapper-specific Extract logic.
func LoadUsageYAML ¶
func LoadUsageYAML(path string) (UsageOverrides, error)
LoadUsageYAML retains the legacy unversioned API.
type UsageRate ¶ added in v0.4.0
type UsageRate struct {
Amount float64
Per float64
Currency string
Source UsageSource
}