# Log Retention

Log retention is the policy and practice of keeping log records available for a defined period before securely deleting them.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/log-retention

> Log retention determines how long operational, security, and audit records remain available for monitoring, investigation, and compliance. An effective policy balances required history and retrieval speed against storage cost, privacy obligations, and protection from unauthorized alteration or deletion.

Practice exams covering Log Retention: [ANS-C01 AWS Certified Advanced Networking - Specialty](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty), [SOA-C03 AWS Certified CloudOps Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate), [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [MLA-C02 (beta) AWS Certified Machine Learning Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate), [SCS-C03 AWS Certified Security - Specialty](https://blowstack.com/practice-exams/aws-certified-security-specialty), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Log Retention

Effective log retention combines complete collection, justified preservation periods, appropriate retrieval performance, deletion protection, and verifiable expiration.

1. **Requirements-based retention periods**: Set durations by log category using investigation needs, applicable obligations, and privacy constraints. Document both minimum preservation requirements and any required deletion deadlines.
2. **Source coverage and delivery continuity**: Identify the administrative, identity, network, application, and data-access events needed for each workload. Verify collection scope and monitor delivery failures so that a retention policy does not conceal missing evidence.
3. **Searchable and archival retention**: Separate the period requiring immediate queries from the total preservation period. Choose storage tiers according to investigation response times, retrieval costs, and restore delays.
4. **Protection against premature deletion**: Use least-privilege access, separation of duties, and immutable storage where required. Retention settings alone do not necessarily prevent administrators or compromised credentials from deleting logs.
5. **Controlled expiration and exceptions**: Automate expiration while accounting for replicas, exports, and noncurrent object versions. Apply approved legal holds when necessary and understand which timestamp starts each retention clock.
6. **Operational validation**: Monitor policy changes, ingestion gaps, and storage growth, and regularly test historical queries or restores. Preserve access to encryption keys and decoding information throughout the required retention period.

## Cloud services for Log Retention

CloudTrail supplies AWS activity records, while CloudWatch Logs collects supported workload and platform logs for operational monitoring. S3 can hold a centralized archive with lifecycle rules and, where required, Object Lock protection. OpenSearch Service can provide an indexed investigation window, while Athena supports queries over accessible S3 log data without maintaining a separate search index. Coordinate retention independently across these stores: deleting an index need not delete the archive, and expiring archive objects does not remove exported copies. Validate delivery, encryption-key access, query performance, and restoration procedures against the required investigation timeline.

- **[Amazon S3](https://blowstack.com/tools/cloud-services-hub/amazon-s3)**: Amazon S3 provides durable storage for centralized log archives, with lifecycle rules for storage-class transitions and expiration. S3 Object Lock can protect object versions using retention periods or legal holds; lifecycle policies must also account for noncurrent versions when deletion is required.
- **[AWS CloudTrail](https://blowstack.com/tools/cloud-services-hub/aws-cloudtrail)**: CloudTrail records AWS account activity, with trails delivering configured events to S3 for retention governed by the destination's policies. Its built-in event history covers 90 days of regional management events and does not replace a configured long-term archive or the explicit collection of required data events.
- **[Amazon OpenSearch Service](https://blowstack.com/tools/cloud-services-hub/amazon-opensearch-service)**: OpenSearch Service supports indexed log analysis when engineers need interactive searches across retained events. Index State Management can automate index transitions and deletion, but indexed retention must be coordinated with any separate archive policy.
- **[Amazon Athena](https://blowstack.com/tools/cloud-services-hub/amazon-athena)**: Athena queries logs stored in S3 without requiring a continuously running search cluster. It does not determine source-log retention; query availability depends on the underlying objects remaining accessible, including restoring archived objects when necessary.

## Log Retention exam questions

Real practice exam questions on Log Retention, with the correct answer and its explanation.

### Question 1 (MLA-C02 (beta))

**Question:**

A company uses an AWS CloudTrail trail to deliver audit logs for its Amazon SageMaker AI workloads to Amazon S3. For newly delivered logs, a regulatory policy requires retention for seven years. During that period, no user, including the AWS account root user, may permanently delete the records or shorten their retention. Logs must remain immediately accessible for the first 90 days; afterward, retrieval within 48 hours is acceptable. Which configuration meets these requirements while reducing long-term storage costs?

**Correct answer:** Enable S3 Object Lock on the destination bucket with a default seven-year retention period in compliance mode. Use an S3 Lifecycle rule to transition log objects to S3 Glacier Deep Archive after 90 days.

**Explanation:** Object Lock compliance mode prevents permanent deletion of protected object versions or shortening of their retention, including by the root user. Lifecycle transitions preserve Object Lock protection. Keeping logs in an immediately accessible storage class initially and transitioning them to Glacier Deep Archive after 90 days reduces archival costs while supporting the allowed retrieval window.

### Question 2 (SAP-C03)

**Question:**

A company uses Amazon Security Lake to collect security logs from its AWS Organizations member accounts in three AWS Regions. Two Regions replicate their collected data to a designated rollup Region. Investigators query the consolidated data in the rollup Region. No storage-class transitions or expiration settings are currently configured.

The company's retention policy requires source-Region copies to expire after 30 days and consolidated copies in the rollup Region to remain available for 400 days. Investigators must be able to query the most recent 30 days of consolidated records without restoring objects. Older consolidated records can require a restore operation that takes several hours. The company wants to reduce storage costs by archiving older consolidated records.

Which configuration meets these requirements?

**Correct answer:** Configure a 30-day expiration in each source Region. In the rollup Region, configure a transition to S3 Glacier Flexible Retrieval after 30 days and expiration after 400 days.

**Explanation:** Security Lake lifecycle settings are regional. The source Regions can expire their copies after 30 days while the rollup Region retains its independently managed copies for 400 days. Transitioning consolidated objects to S3 Glacier Flexible Retrieval after 30 days preserves immediate query access to recent records and provides lower-cost archival storage for older records that can tolerate restoration.

### Question 3 (SOA-C03)

**Question:**

A company has an AWS CloudTrail trail that delivers management events to both an Amazon S3 bucket and a dedicated Amazon CloudWatch Logs log group. An existing S3 Lifecycle rule expires the archived log objects after 365 days. The log group currently retains events indefinitely.

The company requires recent events to remain searchable in CloudWatch Logs Insights for 30 days, after which they must expire automatically from CloudWatch Logs. The 365-day S3 archive must remain unchanged, and the trail must continue delivering events to both destinations.

Which change should a CloudOps engineer make?

**Correct answer:** Set the CloudWatch Logs log group's retention period to 30 days and leave the S3 Lifecycle rule unchanged.

**Explanation:** CloudWatch Logs retention is configured independently for each log group. A 30-day retention policy makes older events eligible for automatic deletion without changing CloudTrail delivery or the S3 archive's 365-day lifecycle.

### Question 4 (AIP-C01)

**Question:**

A company operates a generative AI claims assistant. The application sends two categories of structured events to separate log streams in the same Amazon CloudWatch Logs log group:

• Diagnostic events containing prompts and generated responses.
• Content-free decision records containing the claim ID, model version, guardrail outcome, and timestamp.

The company's privacy policy requires diagnostic events to become eligible for automatic deletion after 7 days. Decision records must remain individually searchable through CloudWatch Logs Insights for 365 days to investigate delayed customer disputes. The company accepts CloudWatch Logs' normal asynchronous deletion behavior. Neither category needs an additional archive.

Which change meets these requirements with the least custom lifecycle-management code?

**Correct answer:** Route the two event categories to separate log groups. Configure a 7-day retention period for the diagnostic log group and a 365-day retention period for the decision-record log group.

**Explanation:** CloudWatch Logs retention is configured per log group, not per log stream. Separate groups allow each category to have its required retention period, and the decision records remain available for Logs Insights queries without custom deletion logic.

### Question 5 (DEA-C01)

**Question:**

A company has 180 days of application audit logs in an Amazon CloudWatch Logs log group whose retention is set to Never expire. To reduce costs, the company must retain only the most recent 30 days in CloudWatch Logs. Before older events are removed, the company must preserve all existing events older than 30 days in an Amazon S3 audit bucket. The bucket is in the same AWS Region, and the required export permissions are configured. Which sequence of actions should a data engineer perform to complete this one-time migration without losing historical logs?

**Correct answer:** Export the existing events older than 30 days to the audit bucket. Wait for the export task to complete successfully and verify the exported coverage, and then set the log group's retention to 30 days.

**Explanation:** A CloudWatch Logs export task copies events from a specified time range to S3 without deleting the source events. Completing and verifying the historical export before shortening retention preserves the required archive. The 30-day retention policy then makes older CloudWatch Logs events eligible for deletion.

### Question 6 (SCS-C03)

**Question:**

A company is preparing to launch a payment workload. Its log agent is configured to send authentication audit events and verbose diagnostic events to separate log streams in the same Amazon CloudWatch Logs log group. The log group has a 14-day retention period.

Fraud investigations can begin more than a year after an authentication event. Investigators therefore require complete authentication records, including the principal, source address, and request identifier, to remain directly searchable in CloudWatch Logs for 400 days. Diagnostic events contain sensitive troubleshooting details and must become eligible for automatic expiration after 14 days. The company wants to avoid retaining either category longer than necessary.

Which change should a security engineer make before launch?

**Correct answer:** Route authentication and diagnostic events to separate log groups. Configure 400-day retention for the authentication log group and 14-day retention for the diagnostic log group.

**Explanation:** Separate log groups provide independent retention controls. This preserves complete, directly searchable authentication records for delayed fraud investigations while making diagnostic records eligible for expiration after 14 days, without unnecessarily extending either retention period.

### Question 7 (DVA-C02)

**Question:**

A developer uses AWS CloudFormation to create an application's Amazon CloudWatch Logs log group. Temporary application stacks are often deleted a few days after testing. Engineers must still be able to investigate each log event for 30 days after it was recorded, even if the stack has been deleted. Older events must expire automatically to limit storage costs, allowing for the normal CloudWatch Logs deletion delay. The log group currently has no explicit retention setting.

Which configuration should the developer apply to the AWS::Logs::LogGroup resource?

**Correct answer:** Set RetentionInDays to 30 and DeletionPolicy to Retain.

**Explanation:** RetentionInDays controls how long log events remain available before automatic expiration. DeletionPolicy: Retain preserves the log group when the stack is deleted, so its 30-day retention policy continues to apply independently of the stack's lifecycle.

### Question 8 (DOP-C02)

**Question:**

A company deploys an application by using AWS CloudFormation. Each deployment stack explicitly manages an Amazon CloudWatch Logs log group. Deployments sometimes replace the log group with a newly named log group, and the pipeline deletes retired stacks.

Security investigators must be able to query every application's log events directly through CloudWatch Logs Insights for 180 days after each event's timestamp, even if the associated stack or log group resource has been replaced or the stack has been deleted. Events older than 180 days must expire automatically, subject to normal service deletion delays, to avoid indefinite storage charges. No separate archive or custom cleanup process is permitted.

Which configuration meets these requirements?

**Correct answer:** Set RetentionInDays to 180 on each log group. Set both DeletionPolicy and UpdateReplacePolicy to Retain on the CloudFormation log group resource.

**Explanation:** RetentionInDays controls event expiration within the log group. DeletionPolicy: Retain preserves the physical log group when its stack is deleted, and UpdateReplacePolicy: Retain preserves the old physical log group during replacement. Retained log groups continue applying their 180-day event retention policy and remain available for Logs Insights queries.

### Question 9 (ANS-C01)

**Question:**

A company collects VPC Flow Logs from workload accounts in two AWS Regions. Each VPC already has two flow log configurations that capture the same traffic: one delivers to a regional Amazon CloudWatch Logs log group, and the other delivers directly to a central Amazon S3 bucket. Both delivery paths are operating successfully. The S3 bucket has versioning disabled.

Network engineers must query the most recent 30 days of records by using CloudWatch Logs Insights. Investigators must also be able to retrieve the original records for 365 days after delivery. Records older than 30 days are rarely accessed, and archive restoration delays of several hours are acceptable. The company wants to minimize ongoing storage costs and avoid custom export or deletion jobs.

Which configuration meets these requirements?

**Correct answer:** Set each CloudWatch Logs log group's retention to 30 days. Configure S3 Lifecycle to transition flow log objects to S3 Glacier Flexible Retrieval after 30 days and expire them 365 days after creation.

**Explanation:** The independently delivered S3 copy preserves the records after they expire from CloudWatch Logs. The 30-day log group retention supports recent Logs Insights queries without retaining unnecessary searchable history. Glacier Flexible Retrieval reduces long-term storage costs and supports standard restores that typically take several hours. Expiration at object age 365 days provides the required archive period.

## Practice Log Retention in a full exam

Questions on Log Retention in each practice exam, with every answer option and an explanation for each:

- [SCS-C03](https://blowstack.com/practice-exams/aws-certified-security-specialty): 9 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 8 questions
- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 6 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 5 questions
- [ANS-C01](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty): 5 questions
- [MLA-C02 (beta)](https://blowstack.com/practice-exams/aws-certified-machine-learning-engineer-associate): 3 questions
- [SOA-C03](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate): 3 questions
- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 1 question
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 1 question

## What is Log Retention

Log retention defines how long log records must remain available and under what conditions they can be deleted. It is separate from log collection: enabling a log source does not guarantee that its records will be stored for the required duration. A complete design specifies the sources, collection scope, storage destinations, retention periods, retrieval expectations, and controls that preserve the records.

Start with workload and security requirements rather than choosing one duration for every log. Administrative API activity, authentication events, network flows, application errors, database audit events, and web access logs answer different investigative questions. Determine which events are needed to detect threats, reconstruct an incident, satisfy contractual obligations, or troubleshoot failures. Confirm whether each source must be explicitly enabled, whether collection covers all relevant accounts and Regions, and whether filtering or sampling could remove required evidence.

Retention periods should reflect the time between an event occurring and someone needing to investigate it. A workload with delayed fraud discovery may need substantially more history than a short-lived development environment. Define both the total retention period and the period during which logs must be immediately searchable. For example, an organization might require 30 days of interactive investigation data and one year of durable archived records. These are example requirements, not universal compliance defaults.

Cloud implementations commonly separate a searchable store from a lower-cost archive. Recent logs support dashboards, alerting, and incident queries, while older records move to storage with lower ongoing costs. The trade-offs include indexing expense, query charges, archive minimum storage durations, retrieval charges, and restore delays. A storage class that requires hours to restore data is inappropriate when investigators must search the full retained history within minutes. Verify that the archive preserves the fields, timestamps, and context needed to reconstruct events.

Retention must work across the entire delivery path. Buffer expiration, failed delivery, missing permissions, or encryption-key problems can create gaps before data reaches its final destination. Monitor ingestion failures, unexpected drops in volume, and changes to retention settings. Test retrieval of older records and retain the necessary decryption keys for as long as the encrypted logs must remain readable. Check whether each system calculates expiration from event time, ingestion time, or object creation time; late-arriving records can otherwise receive less usable retention than intended.

Retention is not the same as immutability or backup. A configured expiration period does not necessarily prevent a privileged user from deleting records early. Where evidence preservation requires stronger protection, combine access separation with immutable storage or legal holds. In versioned object storage, lifecycle rules must also address noncurrent versions when actual removal is required. Legal holds may suspend normal expiration, while privacy requirements may limit unnecessary retention of personal information.

Do not assume that longer retention automatically improves monitoring. Alerts depend on timely ingestion, appropriate event coverage, and effective detection logic; archived records mainly extend retrospective analysis. Likewise, a service's built-in event history is not automatically a long-term archive. On AWS, CloudTrail event history provides the previous 90 days of management events in each Region; longer retention requires a separately configured destination or event data store with suitable retention settings.

## Learn Log Retention in lessons

9 short lessons on Log Retention in 7 certification courses.

- MLA-C02 (beta): Log Retention: configuring retention policies (Premium), https://app.blowstack.com/lessons/log-retention-configuring-retention-policies-mla-c02
- SAP-C03: Log Retention: cost-aware retention tiers (Premium), https://app.blowstack.com/lessons/log-retention-cost-aware-retention-tiers-sap-c03
- SOA-C03: Log Retention: configuring how long logs remain available (Premium), https://app.blowstack.com/lessons/log-retention-configuring-how-long-logs-remain-available-soa-c03
- AIP-C01: Log Retention: tiered retention policies (Premium), https://app.blowstack.com/lessons/log-retention-tiered-retention-policies-aip-c01
- DEA-C01: Log Retention: keeping audit history retrievable (Premium), https://app.blowstack.com/lessons/log-retention-keeping-audit-history-retrievable-dea-c01
- SCS-C03: Immutable Storage vs. Log Retention (Premium), https://app.blowstack.com/lessons/immutable-storage-vs-log-retention-scs-c03
