Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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