Last active
October 27, 2022 00:09
-
-
Save russau/5b878eca39e71bf1dce0a95914f9f2e4 to your computer and use it in GitHub Desktop.
This file contains 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
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