How do you assume a role manually and export the credentials?
IntermediateProductionRapid-Fire AWS CLI
Answer
read AK SK ST <<< $(aws sts assume-role \
--role-arn arn:aws:iam::444455556666:role/Deployer --role-session-name debug-session \
--query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' --output text)
export AWS_ACCESS_KEY_ID=$AK AWS_SECRET_ACCESS_KEY=$SK AWS_SESSION_TOKEN=$ST
Simpler: a profile with role_arn and source_profile in ~/.aws/config, or aws configure export-credentials --profile prod --format env.
More on Rapid-Fire AWS CLI
How do you check which identity and account the CLI is using?BeginnerHow do you log in with Identity Center (SSO) from the CLI?BeginnerHow do you list running instances with name, ID, type and private IP in a table?BeginnerHow do you find the latest Amazon Linux 2023 AMI without hard-coding an ID?BeginnerHow do you open a shell or port-forward to a private instance without SSH?BeginnerHow do you run a command on a fleet of instances by tag?Beginner