Review CloudWatch log retention

Choose CloudWatch log retention to meet investigation, audit and data-retention needs.

Description

retentionInDays controls how long collected events remain. CloudWatch Logs keeps them indefinitely when no retention policy applies.

Potential impact

A short period can remove investigation evidence. A long period increases storage costs and the amount of sensitive data retained.

Remediation

Choose a supported period for your audit and investigation needs. Save any required records before shortening it. Check the effective period after deployment because an account policy can override the group setting. Expired events can take time to disappear.

Examples

Before

yaml
apiVersion: cloudwatchlogs.aws.crossplane.io/v1alpha1
kind: LogGroup
metadata:
  name: lg-3
spec:
  forProvider:
    logGroupName: /aws/eks/sample-cluster/cluster
    region: us-east-1
    retentionInDays: 0

0 is not a supported retention period in the AWS API.

After

yaml
apiVersion: cloudwatchlogs.aws.crossplane.io/v1alpha1
kind: LogGroup
metadata:
  name: lg-1
spec:
  forProvider:
    logGroupName: /aws/eks/sample-cluster/cluster
    region: us-east-1
    retentionInDays: 30

The manifests use different metadata.name values for the same EKS log group. Keep the existing managed resource’s name when changing its retention. The second example requests 30 days.

References