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

Destroying terraform environment can fail to delete database user #13

Open
clarafu opened this issue Jan 19, 2022 · 0 comments
Open

Destroying terraform environment can fail to delete database user #13

clarafu opened this issue Jan 19, 2022 · 0 comments

Comments

@clarafu
Copy link
Contributor

clarafu commented Jan 19, 2022

When I run the terraform destroy job in the environment pipeline, it fails with Error, failed to deleteuser atc in instance <instance-name>. I think this is caused by the fact that terraform tries to delete the user before the database, which it is not allowed to do and results in this error. hashicorp/terraform-provider-google#3820 (comment)

If I run the terraform destroy job a few more times, it seems like randomly it will try to delete the database first (which I think is able to delete it successfully) but then the user is still left in the terraform state and it then errors with Error, failed to deleteuser atc in instance <instance-name>: googleapi: Error 400: Invalid request: Invalid request since instance is not running., invalid.

The way I manually fixed this as a workaround to the issue is to run terraform state list and find the terraform google sql user (it should look like module.baseline_database.google_sql_user.user) and then run 1terraform state rm module.baseline_database.google_sql_user.user`.

But I think maybe the long term fix is to try what is suggested in the issue I linked, where we can try adding a depends_on to the google_sql_database so that it depends on the google_sql_user.

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

No branches or pull requests

1 participant