Skip to content

Instantly share code, notes, and snippets.

@saurabh-hirani
Created May 18, 2018 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurabh-hirani/61d02a3d836f1321dae6d359fc492de1 to your computer and use it in GitHub Desktop.
Save saurabh-hirani/61d02a3d836f1321dae6d359fc492de1 to your computer and use it in GitHub Desktop.
aws-profiles() {
cat ~/.aws/credentials | grep '\[' | grep -v '#' | tr -d '[' | tr -d ']'
}
set-aws-profile() {
local aws_profile=$1
set -x
export AWS_PROFILE=${aws_profile}
set +x
}
set-aws-keys() {
local aws_profile=$1
profile_data=$(cat ~/.aws/credentials | grep "\[$aws_profile\]" -A4)
AWS_ACCESS_KEY_ID="$(echo $profile_data | grep aws_access_key_id | cut -f2 -d'=' | tr -d ' ')"
AWS_SECRET_ACCESS_KEY="$(echo $profile_data | grep aws_secret_access_key | cut -f2 -d'=' | tr -d ' ')"
set -x
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
set +x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment