Skip to content

Instantly share code, notes, and snippets.

@chrisgilbert
Forked from jonnyyu/config
Last active May 5, 2022 14:10
Show Gist options
  • Save chrisgilbert/a6545cd9f95fc4de696f22719439f4f1 to your computer and use it in GitHub Desktop.
Save chrisgilbert/a6545cd9f95fc4de696f22719439f4f1 to your computer and use it in GitHub Desktop.
# add to ~/.aws/config and add the path to your folder.
[serverless-deployments-dev]
role_arn = arn:aws:iam::ACCOUNT_ID:role/ROLE-NAME
role_session_name = SESSION_NAME
region = eu-west-2
#!/bin/bash
# Place in ~/.aws
JQ=`which jq`
CURL=`which curl`
ROLE_NAME="EC2_ASSIGNED_ROLE"
if [ -z "$JQ" ] || [ -z "$CURL" ]
then
echo "Required programs missing."
echo "JQ: $JQ"
echo "CURL: $CURL"
exit 1
fi
$CURL -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${ROLE_NAME} | $JQ '.Version = 1 | .SessionToken = .Token | del(.Token, .Type, .Code, .LastUpdated)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment