Last active
January 5, 2018 12:21
-
-
Save nikhilw/35f537b184eb0d707cb8a48cb32dd324 to your computer and use it in GitHub Desktop.
Revisions
-
nikhilw revised this gist
Jan 5, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,12 +12,13 @@ profile="default" [ "$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` -
nikhilw revised this gist
Jan 5, 2018 . No changes.There are no files selected for viewing
-
nikhilw created this gist
Jan 5, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #! /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 "Choosing 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` 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]