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

Provide more context to terraform providers to avoid accidental resource deletions #410

Open
at-goog opened this issue Nov 8, 2019 · 3 comments
Labels
enhancement New feature or request upstream-protocol Requires change of protocol specification, i.e. can't be done under the current protocol upstream-terraform

Comments

@at-goog
Copy link

at-goog commented Nov 8, 2019

Use-cases

Many resources in GCP are stateful and accidentally deleting them is catastrophic. Due to lack of execution context, a terraform provider may drop and recreate a resource during an update. If providers have more information on which operation was triggered (apply vs destroy), they can choose to never drop certain kinds of stateful resources on apply (e.g. databases, Kubernetes clusters, etc.).

Attempted Solutions

Users can mark their resources with prevent_destroy = true. However, this has 2 issues -

  1. Users must update their template (with prevent_destroy = false) for destroy to go through since lifecycle blocks don't support interpolation.
  2. It requires explicit action from users and they need to be more vigilant about protecting their resources. Providers can do this automatically for them.

Proposal

While delegating work to a terraform provider, if more operational context can be provided (i.e. type of operation = apply vs. destroy, etc.), then provider can take the right action based on the type of resource and the user intent.

References

@paultyng
Copy link
Contributor

I'm going to move this to the SDK, I believe the context is available on the wire, its just not bubbled up from the current SDK to the resource implementations.

@paultyng paultyng transferred this issue from hashicorp/terraform Apr 27, 2020
@paultyng paultyng added the enhancement New feature or request label Apr 29, 2020
@paddycarver
Copy link
Contributor

I'm going to actually disagree with you there, @paultyng. Whether terraform apply or terraform destroy is called, I believe we only get an ApplyResourceChange RPC over the wire. I don't think we get to know whether it was from an apply or a destroy subcommand.

@paddycarver paddycarver added upstream-protocol Requires change of protocol specification, i.e. can't be done under the current protocol upstream-terraform labels Jan 6, 2021
@adejoux
Copy link

adejoux commented Nov 17, 2021

Hello,

+1. Very interested by this feature or something equivalent to avoid accidental delete.

Regards,

Alain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream-protocol Requires change of protocol specification, i.e. can't be done under the current protocol upstream-terraform
Projects
None yet
Development

No branches or pull requests

4 participants