Report but ignore lifecycle.prevent destroy set errors on destroy#38
Open
jmonfar wants to merge 2 commits intofuture-architect:mainfrom
Open
Conversation
about resources with lifecycle.prevent_destroy set. modified: cmd/util.go
modified: cmd/util.go
Collaborator
|
Thanks, I will check this weekend. |
Contributor
Author
|
Hello, kind reminder that the PR is still pending review and action after
around 4 months... It must likely has been forgotten.
--
Jordi Monfar
***@***.***
Missatge de Takafumi Miyanaga ***@***.***> del dia dv., 21 de
març 2025 a les 2:01:
… Thanks, I will check this weekend.
—
Reply to this email directly, view it on GitHub
<#38 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACMAM5VNG3QAEXA57SKAHZ32VNQGHAVCNFSM6AAAAABZOGAJ4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONBRHE4DANZTHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: orangekame3]*orangekame3* left a comment
(future-architect/tftarget#38)
<#38 (comment)>
Thanks, I will check this weekend.
—
Reply to this email directly, view it on GitHub
<#38 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACMAM5VNG3QAEXA57SKAHZ32VNQGHAVCNFSM6AAAAABZOGAJ4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONBRHE4DANZTHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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.
When using the destroy action, if any single resource has the lifecycle.prevent_destroy flag set the whole terraform plan -destroy fails with error, preventing any use of tftarget destroy, even if you intend to use it for other resources without this flag.
In our setup, for example, we have moved our state to s3 backend, and we have prudently set the lifecycle.prevent_destroy flag for the s3 bucket where our states are stored to prevent any accidental removing. This prevents any use of tftarget there.
The proposal is to ignore the error and convert it to a warning, with the following safeguards:
The proposed code is a minimal functional version. It has room for improvement, but at the cost of higher complexity:
As a general criteria, I think that keeping the code as simple as possible will keep it more reliable and easy to maintain.
The current proposal would be the minimum required to keep tftarget usable in setups with protected resources, as the destroy function is in fact the one that justifies most using tftarget versus manual terraform destroy with --target.
If tftarget fails for destroy as a whole, it stops being useful for us and we would not use it.