AWS: AccessDenied
AWSでIAMポリシーによりアクセスが拒否された場合のエラー
概要
AWSリソースへのアクセス時に、IAMポリシーによって必要な権限が付与されていない場合に発生するエラーです。
エラーメッセージ
An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
または
User: arn:aws:iam::123456789012:user/myuser is not authorized to perform: s3:GetObject on resource: arn:aws:s3:::mybucket/mykey
原因
- IAMポリシー不足: 必要なアクションがポリシーで許可されていない
- リソースベースポリシー: S3バケットポリシーなどで拒否されている
- SCPによる制限: Organizations のサービスコントロールポリシー
- 条件の不一致: IPアドレスやMFA条件を満たしていない
解決策
1. IAMポリシーの確認
| |
2. IAM Policy Simulator で検証
| |
3. S3バケットポリシーの確認
| |
4. CloudTrailでログ確認
| |
5. STS で現在のIDを確認
| |
6. AssumeRole の確認
| |
7. MFA条件の確認
| |
8. VPCエンドポイントポリシー
| |
9. Access Analyzer で分析
| |
よくある間違い
- バケット名とバケット内オブジェクトのARNを混同(
arn:aws:s3:::bucketvsarn:aws:s3:::bucket/*) - ワイルドカードの使い方(
*と/*の違い) - クロスアカウントアクセスでプリンシパルの指定ミス
- 暗黙の拒否と明示的な拒否の優先順位
AWS の他のエラー
AccessDeniedException: User is not authorized
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
この記事は役に立ちましたか?