Skip to content

Instantly share code, notes, and snippets.

@timbirk
Forked from xiongchiamiov/why.sh
Created July 2, 2018 09:49
Show Gist options
  • Save timbirk/e7a8355b8826b9b70432611c9901f28d to your computer and use it in GitHub Desktop.
Save timbirk/e7a8355b8826b9b70432611c9901f28d to your computer and use it in GitHub Desktop.
Use this when Amazon gives you an "Encoded authorization failure message" and you need to turn it into something readable. If you only get a request id... you're out of luck.
function decode-authorization-failure-message {
if [ $# -ne 1 ] || [ "$1" = -h ] || [ "$1" = --help ]; then
cat <<'EOT'
Usage: decode-authorization-failure-message <message>
Use this when Amazon gives you an "Encoded authorization failure message" and
you need to turn it into something readable.
EOT
return 1
fi
aws sts decode-authorization-message --encoded-message "$1" |
jq '.["DecodedMessage"]' |
sed 's/\\"/"/g' |
sed 's/^"//' |
sed 's/"$//' |
jq
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment