Connect to Cloud SQL for Postgres using Go and IAM permissions

Stay organized with collections Save and categorize content based on your preferences.

Connect to Cloud SQL for Postgres using Go and IAM permissions to control who/what can connect to your Cloud SQL instances.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Go

d, err := cloudsqlconn.NewDialer(ctx, cloudsqlconn.WithIAMAuthN())
if err != nil {
	return nil, err
}
return d.Dial(ctx, instanceConnectionName)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.