Skip to content

Instantly share code, notes, and snippets.

@tongpu
Created March 5, 2018 16:14
Show Gist options
  • Save tongpu/7825e826fc905e4695de60d0e2951be1 to your computer and use it in GitHub Desktop.
Save tongpu/7825e826fc905e4695de60d0e2951be1 to your computer and use it in GitHub Desktop.
Shell script to export AWS_* environment variables based on the specified profile
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ ${#} = 0 ]; then
profile=default
else
profile=${1}
fi
AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile ${profile})
AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile ${profile})
AWS_DEFAULT_REGION=$(aws configure get region --profile ${profile})
echo export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
echo export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
echo export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment