I am trying to access an s3 bucket in account A from account B.
I followed this guide Cross-account IAM roles option. Then, to assume the role I use this aws cli command in my code:
aws sts assume-role --role-arn "arn:aws:iam::*********:role/cross-account-s3-access" --role-session-name AWSCLI-Session
I can see that the role was assumed:
{
"Credentials": {
"AccessKeyId": "********",
"SecretAccessKey": "********",
"SessionToken": "********",
"Expiration": "2021-07-29T08:46:33Z"
},
"AssumedRoleUser": {
"AssumedRoleId": "********:AWSCLI-Session",
"Arn": "arn:aws:sts::********:assumed-role/cross-account-s3-access/AWSCLI-Session"
}
}
Then, to check if the cross-account access worked, I perform the following command which return access denied:
+ aws s3 ls s3://digibank-endofday-files-stg
An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied
My question is what is the --role-session-name flag? I probably put a wrong value but I couldn't find a proper explanation about it. Where do I find value of it??