# Clear any existing ENV credentials
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
# Assumed the specified role and export the required values
KEYS=$(aws sts assume-role --role-arn $AWS_ROLE_ARN \
--role-session-name testing --duration 900); \
export AWS_ACCESS_KEY_ID=$(echo $KEYS | jq -cr .Credentials.AccessKeyId) && \
export AWS_SECRET_ACCESS_KEY=$(echo $KEYS | jq -cr .Credentials.SecretAccessKey) && \
export AWS_SESSION_TOKEN=$(echo $KEYS | jq -cr .Credentials.SessionToken) && \
echo $AWS_ACCESS_KEY_ID
# Show the caller of the set ENVs/credentials
aws sts get-caller-identity
Last active
February 4, 2022 12:38
-
-
Save marjamis/42bfffd01008081356956d7ed05d23ac to your computer and use it in GitHub Desktop.
Using the AWS CLI for various credential related activities
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment