Cloud SQL for PostgreSQL

Cloud SQL for PostgreSQL is a fully-managed database service for Postgres.

About

Cloud SQL for PostgreSQL is a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on Google Cloud Platform.

If you are new to Cloud SQL for PostgreSQL, you can try creating and connecting to a database by following these instructions.

Requirements

IAM Permissions

By default, this source uses the Cloud SQL Go Connector to authorize and establish mTLS connections to your Cloud SQL instance. The Go connector uses your Application Default Credentials (ADC) to authorize your connection to Cloud SQL.

In addition to setting the ADC for your server, you need to ensure the IAM identity has been given the following IAM roles (or corresponding permissions):

  • roles/cloudsql.client

Tip

If you are connecting from Compute Engine, make sure your VM also has the proper scope to connect using the Cloud SQL Admin API.

Networking

Cloud SQL supports connecting over both from external networks via the internet (public IP), and internal networks (private IP). For more information on choosing between the two options, see the Cloud SQL page Connection overview.

You can configure the ipType parameter in your source configuration to public or private to match your cluster’s configuration. Regardless of which you choose, all connections use IAM-based authorization and are encrypted with mTLS.

Database User

Current, this source only uses standard authentication. You will need to create a PostreSQL user to login to the database with.

Example

sources: my-cloud-sql-pg-source: kind: "cloud-sql-postgres" project: "my-project-id" region: "us-central1" instance: "my-instance" database: "my_db" user: "my-user" password: "my-password" # ipType: "private"

Reference

fieldtyperequireddescription
kindstringtrueMust be “cloud-sql-postgres”.
projectstringtrueId of the GCP project that the cluster was created in (e.g. “my-project-id”).
regionstringtrueName of the GCP region that the cluster was created in (e.g. “us-central1”).
instancestringtrueName of the Cloud SQL instance within the cluster (e.g. “my-instance”).
databasestringtrueName of the Postgres database to connect to (e.g. “my_db”).
userstringtrueName of the Postgres user to connect as (e.g. “my-pg-user”).
passwordstringtruePassword of the Postgres user (e.g. “my-password”).
ipTypestringfalseIP Type of the Cloud SQL instance; must be one of public or private. Default: public.
Last modified February 4, 2025: chore: improve quickstart (#262) (a402c9e)