-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Destroy with deletion_protection
returns a exit code of `
#7869
Comments
(this behaviour can have consequence in a CI setup for example, where a build could be marked as failed while in fact, it succeded) |
Hey, you need to set it to false or it won't delete. There is a note at the top of the docs about this. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance |
Sorry I wasn't clear. I actually DONT want the db to be destroyed. My point is that in that case the destroy command should return no error and an exit code of 0. |
It is not written like that because terraform destroy must remove the resource from the platform. To prevent accidental deletions, that field is in place. What you are describing is equivalent to |
I am not saying the behaviour of |
Using
|
An info log makes sense to me. Maybe something like "The instance has not been deleted because deletion_protection is set to true. Set it to false to proceed with instance deletion" |
Hi, Sorry for the inconvenience, but I feel that the behavior is correct, including the return code. I think that "I ran Will that help? |
To add to @ndmckinley's response (mostly because they got to this right before I did as a response to #7868): I feel that Terraform returning an exit code of |
I disagree since a failure (at least to me) is when something unexcepted happens such as an error. In that particular case, Looks like you guys see that from a different perspective and I got your point :-) All good and thanks again for the assistance. |
Yes, there is plenty of ways to hack this of course. It's just less robust and less readable. |
For context please see also hashicorp/terraform#3874 |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
When running
terraform destroy
on a config withdeletion_protection
set totrue
for agoogle_sql_database_instance
, tf will delete all the resources except thegoogle_sql_database_instance
one and its parent dependencies.But the
terraform destroy
command returns an exit code of 1 with the following error message:It seems to me this behaviour is not correct and the command should return 0 instead since there is no error and not destroying the resource was the correct behaviour.
Am I missing something?
The text was updated successfully, but these errors were encountered: