8

Problem:

I want to be able to granularly create/modify a PostgreSQL CloudSQL instance in Google Cloud Platform with Terraform. Currently there is a setting tier = "<instance_type>"

Example:

Taken from Terraform documentation

  name             = "master-instance"
  database_version = "POSTGRES_11"
  region           = "us-central1"

  settings {
    # Second-generation instance tiers are based on the machine
    # type. See argument reference below.
    tier = "db-f1-micro"
  }
}

Summary:

How Can I modify this to match what I have now? Can I create a custom image to use in GCP?

I see there is a way to make a custom image here, but how would I use it in Terraform?

Current settings in CloudSQL

1 Answer 1

18

The instance tier is the machine type and and for custom machine types you can set the values in that variable like this: db-custom-<CPUs>-<Memory_in_MB> so for example in your case would be:

  name             = "master-instance"
  database_version = "POSTGRES_11"
  region           = "us-central1"

  settings {
    # Second-generation instance tiers are based on the machine
    # type. See argument reference below.
    tier = "db-custom-12-61440"
  }
}

I replicated it on my project and with this values I was able to create an instance with 12 CPUs and 60 GB memory

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.