I'm using Terraform to provision a Google Cloud SQL PostgreSQL database using a google_sql_database_instance resource. I also create a user with a google_sql_user resource.
After applying, I deploy my application which creates databases owned by that user.
The problem is, when I terraform destroy
, Terraform tries to delete the user before it deletes the database. It gets an error (which is expected; you can't delete Postgres users while they own databases). But Terraform doesn't need to delete the user, because the next step is to delete the whole database instance.
Is there a way to tell Terraform that deleting the google_sql_database_instance will have the effect of deleting the google_sql_user, so that Terraform doesn't try to explicity delete the user first and fail?