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

deferred actions: don't plan partial resources during refresh and destroy #36310

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

liamcervante
Copy link
Member

@liamcervante liamcervante commented Jan 13, 2025

When a count or foreach attribute is unknown, deferred actions makes Terraform plan a fake resource that represents any "unknown" resources that might appear once the attribute is known.

This PR skips this step for refresh and destroy plans. In both these cases, there are no potential resources that could appear. We are only interested in resources that we know concretely already exist when destroying and refreshing. If a count or foreach attribute is unknown during a refresh or destroy plan, we can just ignore that part of the configuration and refresh or destroy the resources that are already in state.

Target Release

next alpha

CHANGELOG entry

N/A, deferred actions is still in alpha

@liamcervante liamcervante requested a review from a team as a code owner January 13, 2025 08:21
nfagerlund
nfagerlund previously approved these changes Jan 14, 2025
Copy link
Member

@nfagerlund nfagerlund left a comment

Choose a reason for hiding this comment

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

This logic makes sense to me! Also, I tested a combination of this patch and #36311, and it was able to fully recover from an errored destroy plan on subsequent replans.

@@ -1186,6 +1186,159 @@ func TestApplyDestroy(t *testing.T) {
},
},
},
"destroy-partial-state": {
path: "destroy-corrupted-state",
Copy link
Member

Choose a reason for hiding this comment

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

🤔 Did you wanna rename the testdata as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@liamcervante liamcervante added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Jan 17, 2025
@liamcervante liamcervante merged commit a5c9903 into main Jan 20, 2025
8 checks passed
@liamcervante liamcervante deleted the liamcervante/stacks-destroy branch January 20, 2025 11:18
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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