DEV Community

Shootacean
Shootacean

Posted on • Originally published at shootacean.com

1 2

AWS CLI での EC2 起動時の UnauthorizedOperation エラー

実行したコマンド

aws ec2 run-instances

エラー内容

An error occurred (UnauthorizedOperation) when calling the RunInstances operation: You are not authorized to perform this operation.

エラーメッセージ全体

An error occurred (UnauthorizedOperation) when calling the RunInstances operation: You are not authorized to perform this operation. Encoded authorization failure message: tpNG4Ag3__Co44EMHx-vIkiZHCEGsJXC5WKyizyBzLUqbeLeeTRqDOPoOKB7hkdIpQSxBf2TBSfDgWKLUB5Ra7XAlq1e5ctNRyxcLkvA7kDs4b1CxVah5Yo3IxafEU5KQAD2uN5sHeCwZe2sd4IJUZkOiSNv_w_dSUfOUihgQ80_CJtpb1_lB6vxKRbd7XWAmsLspeun1Q7L3rJJCS8Y0BTVKlKXPDMOIhpjc--cYLsB1MZ0ZCq178BNgFKzv747Ky4NgN4VRUywI1MYiLy9uWzeKc_wGgLM2mJ6JJB8hBvAHprbKQin_J1tuuINAnF85gvFkY6-ieBZ5slajmW69m6WbzqF3ylx50YF9bj_JMDHJtMBVFvT9jgXJz9UDJJVok_D_Lh1oH8A-dC123n9_dDAJrQmo7QZ4oTAQJmP8MBSFvjHRhAEu7Ed4GpKXZyFZPk-IFORkRACNB1a-Wdm3CaYr4-wA8Icu-0g4Vw4BTvnVPlK8Z3MXE4nuIXJivrUh6LvMgftJRqzYWAPaZnL9uM5oLmhlG4OxYQI6e01UYUqf9kanyDQtrVQipEXGnDZQA

原因

起動する EC2 に インスタンスプロファイルを設定していたが、iam:PassRole 権限が無かった。

解決方法

AWS CLIを実行するIAMユーザーのポリシーに iam:PassRole の権限を付与します。

参考

https://aws.amazon.com/jp/blogs/security/granting-permission-to-launch-ec2-instances-with-iam-roles-passrole-permission/

補足

エラーメッセージの Encoded authorization failure message: 以降に出力されている文字列はエンコードされているので、
aws sts decode-authorization-message コマンドでデコードする必要があります。

参考

https://dev.classmethod.jp/cloud/aws/sts-decode-authorization-message/

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more