Closed ralsu091 closed 2 years ago
So it is possible to use Workload Identity with IAM Authn and avoid supplying a password.
Here's what you need to do:
Then your application will be able to log into the database with just the the service account email, in effect using the same IAM account that the proxy is using.
You can test this locally like so:
cloud_sql_proxy --instances project:region:db=tcp:5432 -enable_iam_login -credential_file sa-project-iam.json
And then
psql "host=127.0.0.1 port=5432 user=sa@project.iam dbname=db"
@ralsu091 you may also need a newer version of the Cloud SQL proxy, I'm not sure 1.17 supports IAM DB AuthN
Thanks all. The issue was that the SA didn’t have the cloudsql.instances.login
permission. Once we added it, we were able to connect succefully.
Thank you for the support.