我已经在目标帐户中使用定义了信任关系
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::[SOURCE_ACCOUNT_NUMBER]:root"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
}
我想添加一个条件,以在使用联合身份验证(STS)时仅允许特定用户访问此帐户。因此,我将信任关系修改为:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::[SOURCE_ACCOUNT_NUMBER]:root"
},
"Action": "sts:AssumeRole",
"Condition": {
"Bool": {
"aws:user-name": "[USER-NAME-FROM-SOURCE-ACCOUNT]"
}
}
}
]
}
但是,这种情况没有得到评估。在这种情况下,aws:user-name
正确吗?
参考:https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html
答案 0 :(得分:1)
如果您指定了用户名,则实际上可以在主体字段中指定特定用户,例如:
"Principal": {
"AWS": "arn:aws:iam::123456789012:user/<username>"
},