Which solution will meet these requirements?
Use S3 Inventory to list all objects. Use the AWS CLI to create a script that runs on an Amazon EC2 instance that deletes objects from the inventory list.
Use AWS Batch to delete objects older than 3 years except for the data that must be retained.
Provision an AWS Glue crawler to query objects older than 3 years. Save the manifest file of old objects. Create a script to delete objects in the manifest.
Enable S3 Inventory. Create an AWS Lambda function to filter and delete objects. Invoke the Lambda function with S3 Batch Operations to delete objects by using the inventory reports.
Explanations:
While using S3 Inventory to list all objects and creating a script to delete objects on an EC2 instance could work, it is not serverless and involves managing EC2 infrastructure, which is against the requirement for a serverless solution.
AWS Batch is not necessary for this task and requires provisioning of compute resources, making it not serverless. Additionally, it doesn’t provide an efficient way to directly filter and delete objects in S3 based on their age.
AWS Glue is primarily used for data preparation and ETL tasks, not for direct S3 object deletion. Moreover, provisioning a crawler for this purpose adds unnecessary complexity and does not provide a serverless solution that can efficiently handle deletions based on object age.
Enabling S3 Inventory allows for efficient listing of objects, and using an AWS Lambda function provides a serverless way to filter and delete objects older than 3 years while respecting the retention policy. Invoking the Lambda function with S3 Batch Operations is efficient for processing large numbers of deletions.