AWS Certified Developer – Associate / Question #987 of 557

Question #987

A company runs a logging service on AWS Elastic Beanstalk. The service writes daily system logs to an Amazon S3 bucket. Logs older than 180 days are no longer needed for analysis, and the bucket contains a large volume of outdated logs. A developer must automate the deletion of logs older than 180 days with minimal development effort. Which solution meets this requirement?

A

Modify the application code to include a daily scan of the S3 bucket and delete logs older than 180 days.

B

Develop an AWS Lambda function to periodically scan the S3 bucket and remove logs older than 180 days.

C

Configure an S3 Lifecycle rule for the bucket to expire objects 180 days after creation.

D

Organize logs using a date-based key prefix. Schedule an AWS Lambda function to delete objects with prefixes older than 180 days.

Explanation

Option C is correct because Amazon S3 Lifecycle rules provide a built-in, serverless way to manage object expiration based on age. By setting a rule to expire objects 180 days after creation, outdated logs are automatically deleted, requiring no code changes or maintenance.

Other options are less efficient:
- A requires modifying application code, increasing complexity and maintenance.
- B and D involve developing and maintaining Lambda functions, which adds unnecessary overhead compared to S3-native lifecycle rules.

Key points:
1. S3 Lifecycle rules are ideal for time-based object deletion.
2. Minimal effort solutions prioritize AWS-managed services over custom code.
3. Lifecycle rules apply to all objects in the bucket or specific prefixes, making them flexible and scalable.

Answer

The correct answer is: C