认证考题 | 使用 AWS 云原生功能按需自动删除 S3 存储桶对象


  题目

A company is developing a mechanism that will help data scientists use Amazon SageMaker to read, process, and output data to an Amazon S3 bucket. Data scientists will have access to a dedicated S3 prefix for each of their projects. The company will implement bucket policies that use the dedicated S3 prefixes to restrict access to the S3 objects. The projects can last up to 60 days. The company's security team mandates that data cannot remain in the S3 bucket after the end of the projects that use the data.
Which solution will meet these requirements MOST cost-effectively?
A. Create an AWS Lambda function to identify and delete objects in the S3 bucket that have not been accessed for 60 days. Create an Amazon EventBridge scheduled rule that runs every day to invoke the Lambda function.
B. Create a new S3 bucket. Configure the new S3 bucket to use S3 Intelligent-Tiering. Copy the objects to the new S3 bucket.
C. Create an S3 Lifecycle configuration for each S3 bucket prefix for each project. Set the S3 Lifecycle configurations to expire objects after 60 days.
D. Create an AWS Lambda function to delete objects that have not been accessed for 60 days. Create an S3 event notification for S3 Intelligent-Tiering automatic archival events to invoke the Lambda function.

  参考答案

C

  需求概括

一家公司正在开发一种机制,帮助数据科学家使用 Amazon SageMaker 读取、处理数据,并将数据输出到 Amazon S3存储桶。数据科学家将拥有各自项目专用的 S3前缀访问权限。公司将实施存储桶策略,使用专用 S3前缀限制对 S3对象的访问。项目最长持续60天。公司安全团队要求项目结束后数据不能继续保留在 S3存储桶中。
如何以最具成本效益的方式确保项目结束后自动删除 S3存储桶中的数据?需选择无需持续监控或复杂配置的解决方案,降低运营成本。

  参考解析

技巧:排除明显错误选项,在没有明显错误的选项中选择最合理的选项。

A. 不正确。创建一个 AWS Lambda 函数来识别并删除 S3存储桶中60天内未被访问的对象。创建一个 Amazon EventBridge 定时规则,每天运行以调用该 Lambda 函数。该方案通过 Lambda 函数和 EventBridge 定时触发实现清理,但基于"未访问时间"而非项目结束时间,可能导致项目未结束但数据未被访问时被误删,不符合需求。
B. 不正确。创建一个新的 S3存储桶。配置新存储桶使用 S3 Intelligent-Tiering。将对象复制到新存储桶。此方案仅涉及存储层级优化,未实现数据过期功能,无法满足项目结束后自动删除数据的要求。
C. 正确。为每个项目的每个 S3存储桶前缀创建 S3生命周期配置。设置生命周期配置使对象在60天后过期。该方案直接通过 S3内置的生命周期管理功能,基于时间基准自动删除数据,无需额外服务或持续监控,完全符合需求且成本最低。
D. 不正确。创建一个 AWS Lambda 函数来删除60天内未被访问的对象。为 S3 Intelligent-Tiering 自动存档事件创建 S3事件通知以调用该 Lambda 函数。此方案依赖存档事件触发清理,与项目结束时间无直接关联,且 Intelligent-Tiering 主要用于成本优化,不适合作为数据过期机制。

  技术总结

S3存储桶策略:已通过专用前缀限制访问权限,需进一步配置数据过期策略。
S3 Lifecycle 配置:支持基于时间或访问频率的自动数据过期策略,可以需要实现项目结束后自动删除数据。
S3 Intelligent-Tiering:主要用于存储成本优化,与数据过期无关。
S3事件通知:可基于特定事件(如存档)触发 Lambda,但不适用于时间基准的清理。
AWS Lambda:可通过自定义函数实现数据清理,但需配合触发机制。
Amazon EventBridge:可定时触发 Lambda 函数执行清理任务。