cycloidio / terracost

Cloud cost estimation for Terraform in your CLI
MIT License
286 stars 30 forks source link

Support Terraform provider aliases #31

Closed patrislav closed 3 years ago

patrislav commented 3 years ago

Abstract

Currently, only the Terraform provider without an alias will work. Since in the case of AWS, the only way to define resources in multiple regions is to use provider aliases (with each provider config referencing a different region), this is needed in order to be able to estimate resources in multiple regions.

Implementation details

The provider_name property from both planned_values and prior_state blocks reference the full name of a provider (e.g. registry.terraform.io/hashicorp/aws). From that point, there is no way of retrieving the actual provider config or even its alias. The only way is to cross-reference the configuration block - there the alias will be available under the provider_config_key property (e.g. "aws.alias")