Skip to content

Instantly share code, notes, and snippets.

@denzhel
Created August 17, 2022 21:51
Show Gist options
  • Save denzhel/6aed3f1b09c10ba0a800f600b8bbc2c1 to your computer and use it in GitHub Desktop.
Save denzhel/6aed3f1b09c10ba0a800f600b8bbc2c1 to your computer and use it in GitHub Desktop.
decode AWS encoded error message

When you get this kind of message:

"code": "UnauthorizedOperation",
       "message": "You are not authorized to perform this operation. Encoded authorization failure message: Q92aQ6....

Make sure you have the proper set of IAM rights, I simply use an assumable administrator role:

eval $(aws sts assume-role \
--role-arn arn:aws:iam::1234567:role/mgmt-assumable-role \
--role-session-name test | \
jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\nexport AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)"')

Last, decode the message:

aws sts decode-authorization-message --encoded-message <encdoedMsg> --query DecodedMessage --output text | jq '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment