hashicorp / terraform-config-inspect

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

tfconfig/load_hcl: merge overridden module blocks nicely #15

Closed mildwonkey closed 5 years ago

mildwonkey commented 5 years ago

If a module is overridden and the override does not include "source", use the originally-defined module source.

See also https://github.com/hashicorp/terraform/issues/20550

mildwonkey commented 5 years ago

@apparentlymart : I looked into making the same change in load_legacy.go, but from the looks of this (below) it will fail if there's a module override, because it would register as a repeated module (unless merging the overrides happened elsewhere).

https://github.com/hashicorp/terraform-config-inspect/blob/master/tfconfig/load_legacy.go#L240-L242

apparentlymart commented 5 years ago

I tried to make some sense out of the pre-v0.12 merge code but it's all pretty opaque so I'm not sure really what the behavior was before... but I think you're right that as currently implemented here it would fail.

Ideally it'd behave the same way, so if you can see a relatively-easy path to get there then it'd be nice to fix them both at once, but even if not I think it'd be worth merging this fix because this is the codepath Terraform Core will be using to analyze module dependencies in terraform init once a configuration has been updated for (or originally written for) v0.12, and thus bugs here will effect ongoing use rather than just folks who are migrating.