解码AWS中的加密授权/错误消息

发布于 2025-02-04 18:45:55 字数 28 浏览 3 评论 0原文

一些涉及IAM许可的动作可能会返回客户端。

Some actions that involve IAM permissions may return a Client.UnauthorizedOperation responses.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

嘿嘿嘿 2025-02-11 18:45:56

运行以下代码以更轻松地读取JSON格式的错误。

aws sts decode-authorization-message --encoded-message  <encode_message> --query DecodedMessage --output text | jq '.'

Run this below code for easier reading of the error in JSON format.

aws sts decode-authorization-message --encoded-message  <encode_message> --query DecodedMessage --output text | jq '.'
失退 2025-02-11 18:45:55

您可以使用以下命令从CLI中解密消息:

gt; aws sts decode-authorization-message --encoded-message <encoded message from error>

这将为您提供一个看起来像:

{"allowed":false,"explicitDeny":false,"matchedStatements":{"items":[]},"failures":{"items":[]},"context":{"principal":{"id":"APOZIAANAVSK6I6FK2RQI:i-66c78ee7","arn":"arn:aws:sts::<aws-account-id>:assumed-role/my-role-ec2/i-123456e7"},"action":"iam:PassRole","resource":"arn:aws:iam::<aws-account-id>:role/my-role-ec2","conditions":{"items":[]}}}

错误消息实际上是编码JSON “” ,默认情况下,嵌入式报价() “)被逃脱为\”;要促进阅读错误,请提取消息部分,然后使用文本编辑器将\“ ”替换为“ ”。

You can decrypt the message from the CLI using the following command:

gt; aws sts decode-authorization-message --encoded-message <encoded message from error>

This will give you an output that looks like:

{"allowed":false,"explicitDeny":false,"matchedStatements":{"items":[]},"failures":{"items":[]},"context":{"principal":{"id":"APOZIAANAVSK6I6FK2RQI:i-66c78ee7","arn":"arn:aws:sts::<aws-account-id>:assumed-role/my-role-ec2/i-123456e7"},"action":"iam:PassRole","resource":"arn:aws:iam::<aws-account-id>:role/my-role-ec2","conditions":{"items":[]}}}

The error message is actually encoded JSON inside "", by default the embedded quotes (") are escaped as \"; to facilitate reading the error, extract the message portion and use a text editor to replace \" with ".

べ繥欢鉨o。 2025-02-11 18:45:55

为了使其更可读:

aws sts decode-authorization-message --encoded-message \
[the_message] | jq .DecodedMessage -r | jq

如果您没有JQ,则可以从这里 https:// stedolan。 github.io/jq

To get it more readable:

aws sts decode-authorization-message --encoded-message \
[the_message] | jq .DecodedMessage -r | jq

If you don't have jq you can take it e.g. from here https://stedolan.github.io/jq

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文