Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stacks: fix errors processing index keys of removed blocks #36673

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

liamcervante
Copy link
Member

@liamcervante liamcervante commented Mar 11, 2025

This is part of the work addressing feedback for the removed block in Stacks.

Currently, we were assuming that the for_each attribute was always being copied directly into the key of the from attribute. This isn't necessarily true - there's a test case that has been added that demonstrates this.

This PR updates the Stacks internals to differentiate between the "instance key" of a removed block (which is the output of the for_each evaluation) and the instance key of the address in the from attribute. The each attribute needs to be mentioned in the from attribute, but it doesn't have to be a 1:1 mapping. Previously, we would just check the instance key for direct matches between instances in state, components and removed blocks. Now, we actively check the from attribute of the removed block when making such comparisons.

@liamcervante liamcervante requested a review from a team as a code owner March 11, 2025 13:27
@liamcervante liamcervante added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Mar 11, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a valid test case for this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, these lines: https://github.com/hashicorp/terraform/pull/36673/files#diff-8e06148766db6ff45ec109b3daef7414644336b36abbd1a08a6e0beda95911c7R40-R41

They verify the two new removed blocks are returning errors as expected

@liamcervante liamcervante merged commit 3d014d8 into main Mar 12, 2025
9 of 10 checks passed
@liamcervante liamcervante deleted the liamcervante/stacks/removed-index branch March 12, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants