Skip to content

Instantly share code, notes, and snippets.

@dfevre
Forked from mjul/aws_env
Last active March 4, 2019 21:32
Show Gist options
  • Save dfevre/354b1aeb9a526165dd88d78861d53f2b to your computer and use it in GitHub Desktop.
Save dfevre/354b1aeb9a526165dd88d78861d53f2b to your computer and use it in GitHub Desktop.
Get environment variables from AWS profile (for use with docker-machine)
# 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";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment