Skip to content

Don't attempt to import during a destroy operation#35262

Merged
jbardin merged 1 commit intomainfrom
jbardin/destroy-import
May 31, 2024
Merged

Don't attempt to import during a destroy operation#35262
jbardin merged 1 commit intomainfrom
jbardin/destroy-import

Conversation

@jbardin
Copy link
Copy Markdown
Member

@jbardin jbardin commented May 30, 2024

A full destroy requires Terraform to refresh everything beforehand, but if an instance is missing from the state and has an import block, Terraform was attempting to re-import that resource before destroy. The most common reason this could happen would be when resuming a partially completed destroy, where some of the state has already been deleted. In that case the import will fail with an error because the resource no longer exists, and end up blocking the rest of the operation.

Fixes #35151

A full destroy requires Terraform to refresh everything beforehand, but
if an instance is missing from the state and has an `import` block,
Terraform was attempting to re-import that resource before destroy. The
most common reason this could happen would be when resuming a partially
completed destroy, where some of the state has already been deleted. In
that case the import will fail with an error because the resource no
longer exists, and end up blocking the rest of the operation.
@jbardin jbardin requested a review from a team May 30, 2024 19:24
@jbardin jbardin added the 1.9-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label May 31, 2024
@jbardin jbardin merged commit 611210d into main May 31, 2024
@jbardin jbardin deleted the jbardin/destroy-import branch May 31, 2024 21:20
@github-actions
Copy link
Copy Markdown
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@jbardin jbardin mentioned this pull request May 31, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 1, 2024

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 Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

1.9-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import blocks prevent retrying destroy on error

2 participants