Created
December 5, 2019 15:33
-
-
Save mrchristine/072bf0411375063e15e9c7032e93a450 to your computer and use it in GitHub Desktop.
Decode and pretty print an encoded error message from AWS
This file contains hidden or 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
#!/bin/bash | |
# grab decoded error message | |
error=`aws sts decode-authorization-message --encoded-message $@ | jq .DecodedMessage` | |
# trim the start and end double quotes | |
json_err=${error:1: -1} | |
# remove escaped quoted strings and pretty print with jq | |
echo $json_err | sed 's|\\"|"|g' | jq . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I worked for me after I changed the code like so.
json_err=${error:1:${#error}-1}