According to security best practices, how should an Amazon EC2 instance be given access to an Amazon S3 bucket?
A. Hard code an IAM user’s secret key and access key directly in the application, and upload the file.
B. Store the IAM user’s secret key and access key in a text file on the EC2 instance, read the keys, then upload the file.
C. Have the EC2 instance assume a role to obtain the privileges to upload the file.
D. Modify the S3 bucket policy so that any service can upload to it at any time.
C
技巧:排除明显错误选项,在没有明显错误的选项中选择最合理的选项。
题目的要求是,根据安全最佳实践,Amazon EC2 实例应如何获得对 Amazon S3 存储桶的访问权限。
A. 不正确。直接在应用程序中硬编码 IAM 用户的密钥和访问密钥是非常不安全的,因为一旦代码泄露或被攻击,密钥就可能被滥用。
B. 不正确。将密钥存储在 EC2 实例上的文本文件中同样不安全。这种存储方式容易被恶意用户或软件访问,导致密钥泄露。
C. 正确。让 EC2 实例承担一个角色(即使用 IAM 角色)是最佳实践。用户可以为 EC2 实例配置一个 IAM 角色,该角色具有对 S3 存储桶的访问权限。这样,EC2 实例无需存储或管理密钥,而是使用 AWS 提供的安全机制来获得所需的权限。
D. 不正确。修改 S3 存储桶策略以允许任何服务随时上传文件是极其不安全的,因为这会使存储桶暴露给潜在的恶意用户。