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

Unintentional stateful resource destruction & recreation #35684

Open
luizcavalcanti opened this issue Sep 6, 2024 · 3 comments
Open

Unintentional stateful resource destruction & recreation #35684

luizcavalcanti opened this issue Sep 6, 2024 · 3 comments
Labels
enhancement new new issue not yet triaged

Comments

@luizcavalcanti
Copy link

Terraform Version

Terraform v1.9.5
on linux_amd64

Use Cases

There have been cases in my organization where a customer, when creating a terraform pipeline, used a plan/apply --auto-approve sequence that caused stateful resources to be recreated.

This happened because the provider did not support updating the changed properties, which ends up recreating a cluster and destroying user data.

Attempted Solutions

None

Proposal

I believe we can have a more explicit flag than --auto-approve for when the apply includes deleting and recreating a resource, something like --allow-recreate-resources-without-update-support or something like that.

References

No response

@luizcavalcanti luizcavalcanti added enhancement new new issue not yet triaged labels Sep 6, 2024
@luizcavalcanti luizcavalcanti changed the title Unintentional stateful resource recreation Unintentional stateful resource destruction & recreation Sep 6, 2024
@crw
Copy link
Collaborator

crw commented Sep 6, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@kikoreis
Copy link

kikoreis commented Sep 9, 2024

Oh this is quite timely; we have a user who inadvertently destroyed a TF-created K8s cluster by naively setting --auto-approve in a CI job while using the MGC provider.

It does seem reasonable to have an additional yes-I-am-sure-go-eat-my-data commandline option to complement --auto-approve, in particular given situations like the above (where AIUI the user's template had not changed, but something in the backend provider did). Users who didn't set the option would have the apply just return non-zero and the job would then fail, allowing them to go figure it out.

@kikoreis
Copy link

kikoreis commented Sep 9, 2024

For reference, the docs at https://developer.hashicorp.com/terraform/cli/commands/apply state:

Warning: If you use -auto-approve, we recommend making sure that no one can change your infrastructure outside of your Terraform workflow. This minimizes the risk of unpredictable changes and configuration drift.

However, in the case you're running on public cloud infrastructure, you are implicitly dependent on them, so you can't actually "make sure".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants