Creating a Google_Sql_User with Terraform Always Recreates the Resource

When ever I am running a terraform plan using the following:

resource "google_sql_user" "users" {
    name     = "me"
    instance = "${google_sql_database_instance.master.name}"
    host = "me.com"
    password = "changeme"
    }

This only happens when I am running this a Postgres instance on Google Cloud SQL. Terraform always outputs that the plan will create a user, even though it's already created. I'm using terraform version 0.11.1. Is there something that i'm missing? I tried setting the id value, however there it still recretes itself.

1 Answer

It turns out that the terraform state of the user was not being added, the cause seemed to be that when using postgres, the value host = "me.com" is not required, but causes problems if it's left there.

Once that was removed, then the terraform state will be correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest