daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2.  
  3. # aws cli works with both: environment variables and values configured with `aws configure`.
  4. # If our own script come to use env variables, like in case where we need to guess the url of a ECR reposiroty,
  5. # there is hardly any support to load the profile values into environment.
  6. # This script does just that!
  7.  
  8. set -e
  9. profile="default"
  10. #echo $profile
  11.  
  12. [ "$1" = "" ] || profile=$1
  13. #echo "value: " $1
  14.  
  15. echo "Reading from profile: " $profile
  16.  
  17. export AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id --profile $profile`
  18. export AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key --profile $profile`
  19. export AWS_DEFAULT_REGION=`aws configure get region --profile $profile`
  20.  
  21. # Some custom values added to aws config files
  22. export AWS_ACCOUNT_ID=`aws configure get aws_account_id --profile $profile`
  23. export AWS_PROFILE=`aws configure get aws_profile --profile $profile`
  24.  
  25. echo "new values: " \
  26.     "AWS_ACCESS_KEY_ID: '"$AWS_ACCESS_KEY_ID"', "\
  27.     "AWS_SECRET_ACCESS_KEY: '"$AWS_SECRET_ACCESS_KEY"', " \
  28.     "AWS_DEFAULT_REGION: '"$AWS_DEFAULT_REGION"', " \
  29.     "AWS_ACCOUNT_ID: '"$AWS_ACCOUNT_ID"', " \
  30.     "AWS_PROFILE: '"$AWS_PROFILE"'"
  31.  
  32. # How to run:
  33. # A script cannot export variables into the calling shell, so run it like this:
  34. # . aws_load_config.sh [profile_name]
  35. # OR
  36. # source aws_load_config.sh [profile_name]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top