Connect to Cloud SQL for Postgres using Go and IAM permissions

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

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.