Skip to content

Conversation

@g7r
Copy link

@g7r g7r commented Oct 28, 2025

Terraform stores -replace addresses in a slice that is being passed by reference to graph nodes. When it encounters a replace_triggered_by, it adds the address of the resource that triggered the replacement. The problem is that all graph nodes reuse the same slice. This commit fixes this problem by making a copy of the slice.

Fixes #37831

Target Release

1.15.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

Terraform stores `-replace` addresses in a slice that is being passed by
reference to graph nodes. When it encounters a `replace_triggered_by`,
it adds the address of the resource that triggered the replacement.
The problem is that all graph nodes reuse the same slice. This commit
fixes this problem by making a copy of the slice.
@g7r g7r requested a review from a team as a code owner October 28, 2025 19:21
@github-actions
Copy link
Contributor

Changelog Warning

Currently this PR would target a v1.15 release. Please add a changelog entry for in the .changes/v1.15 folder, or discuss which release you'd like to target with your reviewer. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label.

@crw
Copy link
Contributor

crw commented Oct 28, 2025

Thanks for this submission! Note for future viewers that I believe @jbardin is working on a similar fix (#37833), which I believe would also cover the changes made by this PR. Thanks again!

@crw crw added the bug label Oct 28, 2025
@g7r g7r closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect plan when using replace_triggered_by with -replace

2 participants