I have defined a trust relationship in destination account using
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::[SOURCE_ACCOUNT_NUMBER]:root"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
}
I want to add a condition to allow only a specific user to have access to this account when using federations (STS). So I've modified the trust relationship as:
{
"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]"
}
}
}
]
}
However, this condition is not getting evaluated. Is aws:user-name
right in this case for verifying this condition?
Reference: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html