Courseiva

SAP-C02 Continuous Improvement for Existing Solutions Practice Question

Network Topology
$ aws logs describe-log-groupslog-group-name-prefix /aws/lambda/my-functionRefer to the exhibit.```"logGroups": ["logGroupName": "/aws/lambda/my-function","creationTime": 1704067200000,"metricFilterCount": 1,"arn": "arn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda/my-function:*","storedBytes": 1048576,"retentionInDays": 30

A Lambda function logs are being retained for 30 days. The company wants to reduce costs by deleting logs older than 7 days. What should they do?

⚠ Common exam trap

SAP-C02 often tests whether candidates know that CloudWatch Logs retention is set per log group via put-retention-policy, and distracts with S3 lifecycle policies — candidates who assume CloudWatch logs live in S3 pick the wrong option.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use the put-retention-policy command to set retentionInDays to 7.

CloudWatch Logs retention is controlled per log group via the PutRetentionPolicy API (aws logs put-retention-policy), which sets retentionInDays to a value such as 7. This automatically deletes log events older than the specified period, directly reducing storage costs without changing the logging pipeline. It is the native, lowest-effort solution.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Export the logs to S3 and delete the log group.

    Why it's wrong here

    Exporting to S3 and deleting the log group removes all logs, including the last 7 days the company wants to keep, and breaks future ingestion. It is tempting because S3 storage is cheaper, and this would suit long-term archival where no CloudWatch retention is required.

  • ✓

    Use the put-retention-policy command to set retentionInDays to 7.

    Why this is correct

    Setting a CloudWatch Logs retention policy of 7 days via `put-retention-policy` directly satisfies the stem's cost constraint, since CloudWatch automatically deletes log events once they exceed the configured `retentionInDays` value. This is the native, serverless mechanism for lifecycle management, requiring no custom deletion code or scheduled Lambda invocations.

  • ✗

    Configure an S3 Lifecycle policy on the log group's underlying storage.

    Why it's wrong here

    S3 Lifecycle policies apply to S3 buckets, not CloudWatch Logs log groups, which have no underlying S3 storage to expire. It is tempting because lifecycle rules are the standard expiry mechanism, and this would be correct if the logs were stored in an S3 bucket instead.

  • ✗

    Create a CloudTrail trail to capture log events and expire them after 7 days.

    Why it's wrong here

    CloudTrail records API activity, not Lambda execution logs, so it cannot expire the existing log data. It is tempting because trails are a familiar logging control, and this would be right for auditing API calls rather than managing CloudWatch Logs retention.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

This SAP-C02 question is part of Courseiva's 984-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

This SAP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SAP-C02 exam.