Skip to content

Instantly share code, notes, and snippets.

@codygreen
Last active October 31, 2019 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codygreen/be9598b8ebfc1216b6216c1eb6a0b544 to your computer and use it in GitHub Desktop.
Save codygreen/be9598b8ebfc1216b6216c1eb6a0b544 to your computer and use it in GitHub Desktop.
UDF Cloud Account AWS Share Credentials File
#!/bin/bash
home=/home/ubuntu
creds=$home/.aws/credentials
caURL="http://10.1.1.254/cloudAccounts"
apiKey=`curl -s $caURL | jq '.[][] | .apiKey'`
apiSecret=`curl -s $caURL | jq '.[][] | .apiSecret'`
region=`curl -s $caURL | jq '.[][] | .regions[]'`
sudo -u ubuntu mkdir -p $home/.aws
sudo -u ubuntu touch $creds
sudo -u ubuntu chmod 600 $creds
sudo -u ubuntu cat << EOF > $creds
[default]
aws_access_key_id = $apiKey
aws_secret_access_key = $apiSecret
region = $region
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment