Skip to content

Instantly share code, notes, and snippets.

@gipsh
Created August 4, 2020 14:49
Show Gist options
  • Save gipsh/aa6ac34699fe225d6c7da9172cec913d to your computer and use it in GitHub Desktop.
Save gipsh/aa6ac34699fe225d6c7da9172cec913d to your computer and use it in GitHub Desktop.
set aws credentials into environment
PROFILES=$(awk -F"\\\]|\\\[" '/^\[/{print $2}' ~/.aws/credentials)
select PROFILE in $PROFILES; do
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_DEFAULT_REGION="$(aws configure get region --profile $PROFILE)"
break
done
echo AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
echo AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY|tr '[:print:]' '*')
echo AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION
@gipsh
Copy link
Author

gipsh commented Aug 4, 2020

remember to call it with source: source ./set-aws-env.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment