Description
CloudWatch Logs keeps events indefinitely when no retention policy applies. Check the effective period on existing groups.
Potential impact
A short period can erase evidence needed for an investigation. A long one increases storage costs.
Remediation
Set retention to the number of days your investigations and audits require. Check the effective period after deployment because an account policy can override the group setting. Document any decision to keep logs indefinitely.
Examples
The first task omits retention and purge_retention_policy, so it leaves any existing group-level policy on test-log-group in place. The second requests 30 days. Use amazon.aws.cloudwatchlogs_log_group in new playbooks.
Before
yaml
- name: Create example log group
community.aws.cloudwatchlogs_log_group:
log_group_name: test-log-group
After
yaml
- name: Create example log group
community.aws.cloudwatchlogs_log_group:
log_group_name: test-log-group
retention: 30