hashicorp / terraform-config-inspect

A helper library for shallow inspection of Terraform configurations
Mozilla Public License 2.0
376 stars 76 forks source link

allow parsing of required_providers containing ref #59

Closed jbardin closed 3 years ago

jbardin commented 3 years ago

The syntax for configuration_aliases contains bare references to match their use in other parts of the configuration. These however cannot be decoded directly without an EvalContext, as they represent variables.

Refactor decodeRequiredProvidersBlock to use the lower level hcl.ExprMap function.

While configuration_aliases does define an alternate configuration name for a provider, this PR does not add the alias names to provider_configs because that field is specifically documented as representing a provider block. This is consistent with the handling of un-aliased providers too, since they may also be referenced and have requirements without an explicit configuration block.

jbardin commented 3 years ago

Thanks @radeksimko

Yeah, like I mentioned, I specifically avoided adding these in, because we are currently only exposing configurations. Providers in modules don't always have an associated configuration, aliased or not, and It wasn't clear if we want the information presented to represent only literal configuration blocks.

I can follow up if we want all provider names (which are in essence conceptually referred to as configurations) to be present in the output.