Closed WilliamABradley closed 2 months ago
I would like to see something along the lines of destroyed_with = <parent resource reference>
that marks the resource as destroyed if the referred resource is destroyed
@innovate-invent let's keep this issue focused on only the use-cases it already covers, because three disjoint use-cases in one feature request is already a lot to unpack without throwing in a fourth one! Feel free to open a new feature request issue to discuss what underlying problem would potentially be solved by that destroyed_with
suggestion.
my suggestion specifically relates to the second use case
I like the on_destroy = "retain"
option.
It gets me around a problem I have where I found myself destroy
ing my gandi_livedns_domain
resource while testing. When I attempt to apply
I get an error stating that the domain already exists; terraform doesn't know about it, so it attempts to create one.
I am not sure if this would be considered a bug in the provider, but being able to tell terraform "don't destroy this resource even if I tell you to destroy everything" sounds reasonable in cases like this.
@daraul that is certainly a bug in the provider. If the provider reports that it has destroyed gandi_livedns_domain, yet the object remains, then that is a failure of the provider.
This would be extremely helpful for resource teardown in situations where certain resources cannot be deleted due to security constrains. Many development paradigms at large organizations constrain deletion of certain resources entirely and also restrict directly running commands to alter state. This feature would significantly reduce friction in those situations.
+1 for on_destroy = "retain"
+1 from me!
I'm looking for a way to "abandon" a resources in 30+ workspaces (same codebase). It's a github repository that's now "archived" and I want to get it out my Terraform configuration with leaving the archived repositories out in the wild...
Cloudformation indeed has the "retain" option (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html).
I want this for Terraform. Now I have to go through 30 remote states to do an terraform rm
while simultaniously removing the resource from code. While making sure nobody else starts a TF run....
+1 for this feature, it will make the argument skip_destroy in ECS Task Definitions obsolete.
edit: an argument with the same name also exists for lambda functions.
It looks like there is a removed block, but it seems buried in the documentation and my initial searches didn't find it.
Thanks, indeed removed block should cover this use case. If anyone has related or more nuanced issues surrounding this issue, please open a new ticket. Thanks very much!
removed block isn't really helpful, as it needs to be specified after the fact individually and e.g. outside modules, more like an import, whereas deletion policy in cloudformation or its equivalent suggested here would be specifying on the resource that it should preserved, even when you delete entire modules or the like, whereas prevent_destroy lifecycle errors in your apply instead of only removing the state without touching the real infrastructure.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Current Terraform Version
Use-cases
This feature would cover multiple use cases.
This also matches Cloudformation's Deletion Policy option which allows you to do this.
Attempted Solutions
terraform state rm
achieves this, but it is inconvenient as you have to perform those commands each time, and add scripting.Proposal
Style 1: Combine with prevent_destroy
Style 2: Retain prevent_destroy, but have more than one destroy property
References