AccessDeniedException: User is not authorized
AWS APIでIAM権限が不足している場合に発生するエラー
概要
AccessDeniedException: User: arn:aws:iam::xxx is not authorized to perform は、AWSのAPIを呼び出した際に、IAMユーザーまたはロールに必要な権限がない場合に発生するエラーです。
エラーメッセージ
An error occurred (AccessDeniedException) when calling the DescribeInstances operation: User: arn:aws:iam::123456789012:user/developer is not authorized to perform: ec2:DescribeInstances on resource: *
AccessDeniedException: User: arn:aws:sts::123456789012:assumed-role/MyRole/session is not authorized to perform: dynamodb:GetItem on resource: arn:aws:dynamodb:ap-northeast-1:123456789012:table/MyTable
An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied
原因
1. IAMポリシーに権限がない
| |
2. リソースベースポリシーの制限
S3バケットポリシーなどで明示的に拒否されている場合です。
| |
3. SCPによる制限
Organizations SCPで操作が制限されている場合です。
4. 権限境界(Permissions Boundary)
IAMユーザー/ロールに設定された権限境界で制限されている場合です。
5. 間違った認証情報
別のアカウントの認証情報を使用している場合です。
| |
解決策
1. 現在の認証情報を確認
| |
出力例:
| |
2. 必要な権限を追加
| |
3. IAM Policy Simulatorで検証
AWS ConsoleのIAM Policy Simulatorを使って、どの権限が不足しているか確認できます。
4. CloudTrailでエラーを確認
| |
5. 最小権限の原則に従った設定
| |
6. AssumeRoleの確認
クロスアカウントやロール切り替え時は信頼ポリシーも確認します。
| |
よくあるケース別対処
Lambda関数からのアクセス
| |
ECS タスクからのアクセス
タスクロール(taskRoleArn)に権限を付与します。
| |
デバッグ手順
| |
関連エラー
関連エラー
AWS の他のエラー
ECS CannotPullContainerError
AccessDenied: User is not authorized to perform sts:AssumeRole
IncompleteSignature: The request signature we calculated does not match
MissingAuthenticationToken: Missing Authentication Token
SignatureDoesNotMatch: The request signature we calculated does not match
UnrecognizedClientException: The security token included in the request is invalid
この記事は役に立ちましたか?