LoginSignup
5
2

More than 1 year has passed since last update.

AWSのエンコードされたエラーメッセージをデコードして読みやすくするメモ

Last updated at Posted at 2021-08-20

毎度調べてるので、自分のためのメモ

エンコードされたAPIエラー

コンソールやCLIでの操作時やCloudTrailなんかで見かけるこいつ。

 "errorMessage": "You are not authorized to perform this operation. Encoded authorization failure message: むにゃむにゃむにゃ",

どうしてエンコードしちゃうのさ

余計なことを・・・!と思っていた時期が私にもありました。

ドキュメントに書いてあった
https://docs.aws.amazon.com/STS/latest/APIReference/API_DecodeAuthorizationMessage.html

The message is encoded because the details of the authorization status can contain privileged information that the user who requested the operation should not see. To decode an authorization status message, a user must be granted permissions through an IAM policy to request the DecodeAuthorizationMessage (sts:DecodeAuthorizationMessage) action.

オペレーションをリクエストしたユーザーが見るべきではない特権情報が含まれている可能性があるから、ってことですね。
具体的にどんなシチュエーションなのかは思いつかないけど、気を遣ってもらってると捉えておきます。

CloudShellでやってみる

aws cliはもちろんjqも入ってたので話が早いです。

$ aws sts decode-authorization-message --encoded-message デコードしたい文字列 | jq .DecodedMessage --raw-output | jq .

こんな感じで読める状態になります。
sts-decode_cloudshell.png

感想

いまのところCloudShellって、こういう本当にちょっとした時に一番使い道を感じますね。

参考

https://docs.aws.amazon.com/STS/latest/APIReference/API_DecodeAuthorizationMessage.html
https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-not-auth-launch/
https://qiita.com/YumaInaura/items/153b7f80c00fa199a0a8

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2