0
votes

How can I set AutoResizeLimit when creating a Cloud SQL MySQL instance? The GCP API defines it here: https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances The terraform provider has disk_autoresize, which is a boolean: https://www.terraform.io/docs/providers/google/r/sql_database_instance.html#disk_autoresize

But, there is no attribute to set the auto_resize_limit.

1

1 Answers

0
votes

A way to create a Cloud SQL instance with auto_resize_limit is to create it directly with querying an API e.g. with cURL and setting storageAutoResizeLimit.

The query should look like this:

ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     --header 'Content-Type: application/json' \
     --data '{"name":"[INSTANCE_NAME]", "region":"[REGION]",
              "settings": {"tier":"[MACHINE_TYPE]",
              "storageAutoResizeLimit":[SIZE],
              "backupConfiguration": {"binaryLogEnabled":true, "enabled":true}}}' \
     -X POST \
     https://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances

Note that storageAutoResize is set to True by default.