Creating a CloudSQL instance with terraform and custom tier
Asked Answered
B

1

11

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

Bumblebee answered 4/11, 2020 at 15:22 Comment(0)
P
24

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

Procathedral answered 4/11, 2020 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.