Skip to content

Instantly share code, notes, and snippets.

@advincze
Created November 6, 2018 21:12
Show Gist options
  • Save advincze/decbb33d7838c694bb21bd69ff83e543 to your computer and use it in GitHub Desktop.
Save advincze/decbb33d7838c694bb21bd69ff83e543 to your computer and use it in GitHub Desktop.
ROLE_NAME=arn:aws:iam::123456789123:role/my_role_to_assume
AWS=$(aws sts assume-role --role-arn $ROLE_NAME --role-session-name foo --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' --output text | awk '{print "AWS_ACCESS_KEY_ID=" $1,"AWS_SECRET_ACCESS_KEY=" $2, "AWS_SESSION_TOKEN=" $3}')
env -S $AWS aws s3 ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment