Created
November 7, 2017 15:32
-
-
Save cmaggiulli/cafbcbb0d91185b47358dca149ac2ef7 to your computer and use it in GitHub Desktop.
AWS Key setup for CLI and Programmatic use on Linux
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 characters
| #!/bin/bash | |
| # To run this use the following commands | |
| # ---------------------------------- | |
| # sudo chmod +x aws-config-linux.sh | |
| # sudo . aws-config-linux.sh access_key_id secret_access_key | |
| fldr=~/.aws | |
| cred=$fldr/credentials | |
| access_key_id=$1 | |
| secret_access_key=$2 | |
| if [ ! -d $fldr ]; then | |
| mkdir $fldr | |
| else | |
| echo "Directory $fldr already exists!" | |
| fi | |
| if [ ! -e $cred ]; then | |
| echo -e "[default]\naws_access_key_id = $access_key_id\naws_secret_access_key = $secret_access_key" >> $cred | |
| else | |
| echo "File $cred already exists!" | |
| fi | |
| env AWS_ACCESS_KEY_ID=$access_key_id | |
| env AWS_SECRET_ACCESS_KEY=$secret_access_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment