Skip to content

Instantly share code, notes, and snippets.

@kwoods
Last active November 6, 2020 17:00
Show Gist options
  • Save kwoods/5ceca1dc793270ea2790d043ef01800b to your computer and use it in GitHub Desktop.
Save kwoods/5ceca1dc793270ea2790d043ef01800b to your computer and use it in GitHub Desktop.
ZSH Shell Function for populating ENV with AWS Keys from ~/.aws/credentials profiles
# Usage: aws_env_helper <profile-name-in-aws-credentials>
# add this to your ~/.zshrc
aws_env_helper () {
readonly profile=${1:?"The aws profile must be specified."}
export AWS_ACCESS_KEY_ID="$(aws configure get aws_access_key_id --profile $profile)"
export AWS_SECRET_ACCESS_KEY="$(aws configure get aws_secret_access_key --profile $profile)"
export AWS_SESSION_TOKEN="$(aws configure get aws_session_token --profile $profile)"
export AWS_PROFILE=$profile
export AWS_RETRY_MODE=adaptive
export AWS_MAX_ATTEMPTS=10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment