Skip to content

Instantly share code, notes, and snippets.

@jpriebe
Created January 31, 2023 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpriebe/aa437dd34af4684f6a58f1f229bd715c to your computer and use it in GitHub Desktop.
Save jpriebe/aa437dd34af4684f6a58f1f229bd715c to your computer and use it in GitHub Desktop.
assume_role
assume_role () {
SESSION_NAME=$1
ROLE_ARN=$2
export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \
$(aws sts assume-role \
--role-arn $ROLE_ARN \
--role-session-name $SESSION_NAME \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text))
aws sts get-caller-identity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment