terraform-provider-google: googleapi: Error 400: Invalid request: Failed to delete user root.
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
- If an issue is assigned to the “modular-magician” user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to “hashibot”, a community member has claimed the issue already.
Terraform Version
Terraform v0.11.13
- provider.google v2.7.0
- provider.google-beta v2.7.0
Affected Resource(s)
- google_sql_user
Terraform Configuration Files
resource "google_sql_database_instance" "<name>-db-instance" {
name = "<name>-db-instance"
region = "${var.region}"
database_version = "POSTGRES_9_6"
settings {
tier = "db-f1-micro"
...
}
}
resource "google_sql_database" "<name>-db" {
name = "<name>-db"
instance = "${google_sql_database_instance.<name>-db-instance.name}"
}
resource "google_sql_user" "<name>-db-user" {
instance = "${google_sql_database_instance.<name>-db-instance.name}"
name = "root"
password = "${random_string.<name>-db-password.result}"
}
Panic Output
* google_sql_user.<name>-db-user: Error, failed to deleteuser <name>-db-user in instance <name>-db-instance: googleapi: Error 400: Invalid request: Failed to delete user <name>-user. Detail: pq: role "<name>-db-user" cannot be dropped because some objects depend on it
Expected Behavior
Terraform should destroy the user and database successfully on the first run.
Actual Behavior
Database and user aren’t deleted on the first run. Re-run (with the same code) deletes successfully (sometimes require more than one re-run).
Steps to Reproduce
terraform destroy
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 18
- Comments: 24 (5 by maintainers)
@kenmazaika we actually use gcloud commands to tear the instance down, prior to that call we use terraform to remove the state for the db and its databases and users. We basically gave up on terraform doing the teardown. So in our bash that calls terraform (we use concourse pipelines), we first use gcloud to delete the instance and then we remove all the state, then we go about regular TF activities.
@kenmazaika that’s what we did, we remove the state and we actually use gcloud to tear the instance down.
We have the same problem as well.