Skip to content

Question on get-caller-identity

0

aws sts get-caller-identity command shows a role name that is attached to an EC2 instance. How do I change it to an IAM username as I set it in aws configure command?

2 Answers
4
Accepted Answer

It seems, you already configured user profile, then just run the command this way:

 aws sts get-caller-identity --profile <profile_name>

You can find profile name for the configured user at ~/.aws/config file. If you want to export ACCESS_KEY and SECRET_ACCESS_KEY in environment then you can simply export those in environment and run command:

aws sts get-caller-identity 

This would also return the same user identity.

Reference: How to configure AWS CLI

AWS
EXPERT

answered 3 years ago

AWS
EXPERT

reviewed 3 years ago

0

You can use the parameter --profile to use your current credentials set in aws confgure.

Check the links bellow to get more information: https://docs.aws.amazon.com/cli/latest/reference/sts/get-caller-identity.html https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html

AWS

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.