Skip to content

Instantly share code, notes, and snippets.

@russau
Last active October 27, 2022 00:09
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 russau/5b878eca39e71bf1dce0a95914f9f2e4 to your computer and use it in GitHub Desktop.
Save russau/5b878eca39e71bf1dce0a95914f9f2e4 to your computer and use it in GitHub Desktop.
keys=($(aws sts assume-role --role-arn "arn:aws:iam::012345678912:role/ec2-readonly-role" \
--role-session-name session1 \
--query "[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]" \
--output text))
export AKI=${keys[1]} ; export SAK=${keys[2]} ; export ST=${keys[3]}
curl 'https://ec2.ap-southeast-2.amazonaws.com/?Action=DescribeInstances' \
--aws-sigv4 aws:amz:ap-southeast-2:ec2 \
--user "${AKI}:${SAK}" \
--header "x-amz-security-token: ${ST}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment