This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Assume the given role, and print out a set of environment variables | |
# for use with aws cli. | |
# | |
# To use: | |
# | |
# $ eval $(./iam-assume-role.sh) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following is a ~/.zshrc function that exports an aws cli profile from ~/.aws/credentials to environment variables. | |
aws_env() { | |
export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile "$1"); | |
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile "$1"); | |
export AWS_SESSION_TOKEN=$(aws configure get aws_session_token --profile "$1"); | |
export AWS_SECURITY_TOKEN=$(aws configure get aws_security_token --profile "$1"); | |
export AWS_DEFAULT_REGION=$(aws configure get region --profile "$1"); | |
echo "$1 environment variables exported"; | |
} |