Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- # aws cli works with both: environment variables and values configured with `aws configure`.
- # If our own script come to use env variables, like in case where we need to guess the url of a ECR reposiroty,
- # there is hardly any support to load the profile values into environment.
- # This script does just that!
- set -e
- profile="default"
- #echo $profile
- [ "$1" = "" ] || profile=$1
- #echo "value: " $1
- echo "Reading from profile: " $profile
- 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`
- # Some custom values added to aws config files
- export AWS_ACCOUNT_ID=`aws configure get aws_account_id --profile $profile`
- export AWS_PROFILE=`aws configure get aws_profile --profile $profile`
- echo "new values: " \
- "AWS_ACCESS_KEY_ID: '"$AWS_ACCESS_KEY_ID"', "\
- "AWS_SECRET_ACCESS_KEY: '"$AWS_SECRET_ACCESS_KEY"', " \
- "AWS_DEFAULT_REGION: '"$AWS_DEFAULT_REGION"', " \
- "AWS_ACCOUNT_ID: '"$AWS_ACCOUNT_ID"', " \
- "AWS_PROFILE: '"$AWS_PROFILE"'"
- # How to run:
- # A script cannot export variables into the calling shell, so run it like this:
- # . aws_load_config.sh [profile_name]
- # OR
- # source aws_load_config.sh [profile_name]
Add Comment
Please, Sign In to add comment