A developer operations team uses AWS Identity and Access Management (IAM) to manage user permissions. The team created an Amazon EC2 instance profile role that uses an AWS managed ReadOnlyAccess policy. When an application that is running on Amazon EC2 tries to read a file from an encrypted Amazon S3 bucket, the application receives an AccessDenied error. The team administrator has verified that the S3 bucket policy allows everyone in the account to access the S3 bucket. There is no object ACL that is attached to the file.
What should the administrator do to fix the IAM access issue?
A. Edit the ReadOnlyAccess policy to add kms:Decrypt actions
B. Add the EC2 IAM role as the authorized Principal to the S3 bucket policy
C. Attach an inline policy with kms:Decrypt permissions to the IAM role
D. Attach an inline policy with S3:* permissions to the IAM role
C
一个开发运维团队使用 AWS Identity and Access Management (IAM)管理用户权限。该团队创建了一个 Amazon EC2实例配置角色,该角色使用 AWS 管理的 ReadOnlyAccess 策略。当运行在 Amazon EC2上的应用程序尝试从加密的 Amazon S3存储桶读取文件时,应用程序收到 AccessDenied 错误。团队管理员已验证 S3存储桶策略允许账户中的所有人访问该 S3存储桶。该文件未附加任何对象 ACL。
如何解决 EC2实例上应用程序因缺少 KMS 解密权限而无法访问加密 S3存储桶中文件的问题?
应用程序收到 AccessDenied 错误,表明权限不足。S3存储桶策略已允许账户内所有用户访问,且无对象 ACL 限制,因此问题可能出在 IAM 角色权限或 KMS 密钥权限。
技巧:排除明显错误选项,在没有明显错误的选项中选择最合理的选项。
A. 不正确。编辑 ReadOnlyAccess 策略以添加 kms:Decrypt 操作。AWS 管理的策略(如 ReadOnlyAccess)通常不可编辑,此操作不可行。
B. 不正确。将 EC2 IAM 角色作为授权主体添加到 S3存储桶策略。S3存储桶策略已允许账户内所有用户访问,问题不在于存储桶策略,因此此操作无效。
C. 正确。将具有 kms:Decrypt 权限的内联策略附加到 IAM 角色。此操作直接解决了缺少 KMS 解密权限的问题,符合最小权限原则,是正确的解决方案。
D. 不正确。将具有 S3:权限的内联策略附加到 IAM 角色。虽然此操作可解决问题,但过度授权(S3:)违反最小权限原则,存在安全风险,不是最佳实践。
KMS 加密与解密:S3存储桶使用 KMS 加密,访问加密对象需要 kms:Decrypt 权限,AWS 管理的 ReadOnlyAccess 策略不包含 kms:Decrypt 权限,因此需要额外授权。
IAM 角色与策略:EC2实例使用 IAM 角色获取权限,需确保角色具有访问加密对象所需的权限。
最小权限原则:应仅授予必要的权限(如 kms:Decrypt),避免过度授权(如 S3:*)。