我正在尝试让IAM用户使用IAM凭据访问AWS RDS PostgreSQL,并且如果在IAM策略中指定了PAM authentication failed for user
,则会收到错误DbiResourceId
。 1.我按照in the documentation所述创建了IAM策略。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"arn:aws:rds-db:us-west-2:<My_account_id>:dbuser:<My_DbiResourceId>/readwrite_user"
]
}
]
}
2。创建的数据库用户:
CREATE USER readwrite_user WITH LOGIN;
GRANT rds_iam TO readwrite_user;
GRANT CONNECT ON DATABASE database_iam_test TO readwrite_user;
3。尝试连接
export PGPASSWORD="$(aws rds generate-db-auth-token --hostname $RDSHOST --port 5432 --region $REGION --username $DBUSERNAME)"
psql -h $RDSHOST -p 5432 "dbname=database_iam_test user=$DBUSERNAME sslrootcert=./rds-combined-ca-bundle.pem sslmode=verify-ca"
在这种情况下,我有错误:
psql: error: could not connect to server: FATAL: PAM authentication failed for user "readwrite_user"
但是如果我使用*而不是DbiResourceId-它正在工作!因此,此政策有效:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"arn:aws:rds-db:us-west-2:<My_account_id>:dbuser:*/readwrite_user"
]
}
]
}
我只有一个数据库资源,并且我确定我使用了正确的DbiResourceId,它在我的设置中由命令返回:]
aws rds describe-db-instances --query "DBInstances[*].[DBInstanceIdentifier,DbiResourceId]" --region $REGION
有人可以解释为什么在这种情况下指定
DbiResourceId
会导致错误吗?
我正在尝试让IAM用户使用IAM凭据访问AWS RDS PostgreSQL,并且如果IAM策略中指定了DbiResourceId,则用户的错误PAM身份验证失败。 1.我将IAM策略创建为...
我将IAM策略中DbiResourceId的值从DBInstancesId更改为ClusterID,并解决了问题。