Repository navigation
feat: show resources by their Terraform address - #107
Merged
Merged
Conversation
Resources inside modules were labelled kind-first (aws_instance.module.tier["web"].this[0]), which Terraform does not accept, in every output and PR comment. Label() now returns the Terraform address (module.tier["web"].aws_instance.this[0]); the old form is LegacyLabel(). Usage-file keys and --what-if accept the Terraform address (which the usage docs already promised; such keys were silently unmatched) and still accept the old form with a warning. Diffs and baselines match on kind and name, so saved baselines are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Resources inside modules are now shown by their Terraform address in every format and PR comment.
aws_instance.module.tier["web"].this[0]module.tier["web"].aws_instance.this[0]aws_db_instance.module.a.module.b.mainmodule.a.module.b.aws_db_instance.mainaws_instance.web[0]aws_instance.web[0](unchanged outside modules)Label()now returnsTerraformAddress(), which already existed fortop --format targets. The old form is kept asLegacyLabel(). CSV and the diff formats, which built the string by hand, now useLabel().Compatibility
ComputeDiffmatches onkindandname, not on the label.TestBaselineFromBeforeTerraformAddressesStillDiffsdecodes a pre-change baseline and gets one modified resource, not an added/removed pair.internal/usagehas documented that form (module.frontend.aws_instance.web) all along, but such keys were silently unmatched and their usage ignored. Legacy keys still match, and the CLI warns with the new key to use. If a file has both, the Terraform address wins and the legacy key is reported as unmatched.--what-if: acceptsmodule.web.aws_instance.this[0].instance_type=…, splitting only on dots outside[...], sologs["a.b"]keys work. The legacy form still parses to the same resource, with a warning. An incomplete module address is rejected.resourcechanges to the address;kindandnameare unchanged. The CHANGELOG calls this out for scripts.Tests
LabelequalsTerraformAddress,LegacyLabelis kept, and both are identical outside modules.monorepo-with-modules.md: the only change is the five module labels.