1 Answer
- Newest
- Most votes
- Most comments
3
If you refer AWS CLI Configuration Variables documentation, take a look at section Using AWS IAM Roles.
I'm not sure why you'd setup CLI to assume role in same account. Refer re:Post Knowledge Center Article for same account IAM Assume Role CLI.
For cross account setup, your entry should look like as below:
# In ~/.aws/credentials:
[regionsadmin]
aws_access_key_id = ******
aws_secret_access_key = ******
# In ~/.aws/config
[profile crossaccount]
region = us-east-1
output = json
source_profile = regionsadmin
role_arn=arn:aws:iam::****:role/regionsclirole
For same account setup, your entry should look like as below:
# In ~/.aws/credentials:
[regionsadmin]
aws_access_key_id = ******
aws_secret_access_key = ******
# In ~/.aws/config
[profile crossaccount]
region = us-east-1
output = json
source_profile = regionsadmin
role_arn=arn:aws:iam::****:role/regionsclirole
Edit:
I just tested this in house and it works absolutely fine as expected even within same account. User for which I saved credentials, had only sts assume role permissions where as the role which it assumed had getsecretvalue permissions. Attaching snapshot for your reference:
Hope you find this useful.
Comment here if you have additional questions, happy to help.
Abhishek
Relevant content
- asked 4 years ago

Now I'm getting a new error
I'm curious, why do you need to setup CLI this way as this setup is more suited for cross account. Doesn't sts:assumerole fit more into your requirement as described here.
I just tested this in house for same account setup as well, and it worked fine. User for which I saved credentials in credentials file, had only sts assume role permissions where as the role which it assumed had getsecretvalue permissions. I'd suggest you to take a look at your configuration once more and see if you find something incorrect. May be you can paste your config and credentials entry again after masking account and credentials info. I can take another look at your files.
Yes, I had followed the same procedure using a different AWS doc. The one you have provided is better. I was able to run the AWS command. Thank you