psql:错误:致命:用户的 Cloud SQL IAM 服务帐户身份验证失败

问题描述 投票:0回答:1

我已按照以下说明使用 IAM 身份验证设置了我的云 sql 数据库:

https://binx.io/2021/05/19/how-to-connect-to-a-cloudsql-with-iam-authentication/

我正在尝试从云计算实例进行身份验证。我的数据库已连接:

gcloud sql users list --instance=db1-instance-e740ca44
NAME              HOST  TYPE                       PASSWORD_POLICY
postgres                BUILT_IN
sa-cloudsql-user        CLOUD_IAM_SERVICE_ACCOUNT

IAM 身份验证已启用:

gcloud sql instances describe db1-instance-e740ca44 --format json | jq '.settings.databaseFlags'
[
  {
    "name": "cloudsql.iam_authentication",
    "value": "on"
  }
]

但是我在尝试连接时仍然收到以下错误:

psql "host=127.0.0.1 port=5432 sslmode=disable dbname=postgres user=sa-cloudsql-user"
psql: error: FATAL:  Cloud SQL IAM service account authentication failed for user "sa-cloudsql-user"

我什至尝试向 sa-cloudsql-user 服务帐户和我的计算实例运行的服务帐户授予所有者权限,以确保这不是 IAM 权限问题,但没有骰子。

大家有什么想法吗?

postgresql google-cloud-platform google-cloud-sql
1个回答
0
投票

我不知道这是否仍然与您相关,但这对我来说是一个问题。 CLI 工具 ./cloud-sql-proxy 必须使用以下标志运行:

--auto-iam-authn 
--credentials-file={key-file-of-your-SA}
© www.soinside.com 2019 - 2024. All rights reserved.