Skip to main content
Provision and manage Cloud SQL database instances with databases and users on Google Cloud Platform.
Cloud SQL resources form a hierarchy: Instance → Database → User.

gcp/cloudsql/database_instance

Creates a managed Cloud SQL instance (PostgreSQL, MySQL, or SQL Server).

Config

FieldTypeRequiredDefaultDescription
project_idstringYesGCP project ID (immutable)
credentialsdict or stringYesGCP service account credentials JSON
regionstringYesGCP region, e.g., europe-west4 (immutable)
instance_namestringYesInstance name, 1–98 chars, starts with letter (immutable)
database_versionstringNo"POSTGRES_15"Database version (immutable). Supported: POSTGRES_*, MYSQL_*, SQLSERVER_*
tierstringNo"db-f1-micro"Machine tier (e.g., db-custom-1-3840)
availability_type"ZONAL" | "REGIONAL"No"ZONAL"Single zone or high availability
backup_enabledbooleanNotrueEnable automatic backups
deletion_protectionbooleanNofalsePrevent accidental deletion
authorized_networkslist[string]No[]CIDR ranges allowed to connect
enable_public_ipbooleanNotrueAssign a public IP address

Outputs

FieldTypeDescription
connection_namestringCloud SQL connection name (project:region:instance)
public_ipstring or nullPublic IP address
private_ipstring or nullPrivate IP address
readybooleanWhether the instance is running
console_urlstringURL to GCP Console
logs_urlstringURL to Cloud Logging

Example

provider: gcp
resource: cloudsql/database_instance
name: main-db
config:
  project_id: my-project
  credentials:
    type: service_account
    # ... service account JSON
  region: europe-west4
  instance_name: main-postgres
  database_version: POSTGRES_15
  tier: db-custom-1-3840
  availability_type: ZONAL
  backup_enabled: true
  authorized_networks:
    - "0.0.0.0/0"

Dependencies

gcp/cloudsql/database_instance
  ├─▶ gcp/cloudsql/database
  └─▶ gcp/cloudsql/user
The database and user resources depend on an instance. Changing the instance on a database or user triggers replacement (delete from old, create in new).

Notes

  • Instance creation takes several minutes. The resource polls until the instance reaches RUNNABLE state.
  • Fields marked (immutable) cannot be changed after creation — you must delete and recreate the resource.
  • Password changes on users are applied in place without recreation.
  • All Cloud SQL resources are idempotent — creating an existing resource returns its current state.