# Log retention

Set how long a CloudWatch log group keeps its events, see what it stores, and what happens when CloudFormation, CDK or Terraform manages it.

CloudWatch Logs keeps events forever unless a log group has a retention, and stored logs are billed every month. To change it, open the log group (Services → Logs) and tap **Retention**.

Screenshot: Retention sheet for /ecs/checkout-api with a warning that CloudFormation stack checkout-service manages it

## Pick a retention

The sheet lists every value CloudWatch Logs accepts, from 1 day to 10 years, plus **Never expire**. The current one is ticked, and for a group that never expires 1 month is marked **Suggested**. The sheet also says how much the group stores now.

Shortening retention is confirmed like any other change, at the level you set for the account (by default, typing the last part of the group’s name). CloudWatch Logs then deletes events older than the new period, usually within 72 hours, and they can’t be brought back.

## Managed by CloudFormation, CDK or Terraform

If the log group belongs to a CloudFormation stack, or its tags show it is managed by a tool such as Terraform, Pulumi or the Serverless Framework, the sheet warns you before you choose: the change works, but the next deploy (a stack update, `cdk deploy`, `terraform apply`…) can put the template’s value back. Set `RetentionInDays` (or `retention_in_days`) in the code to make it stick; **Open stack** takes you to the stack.

When only the Lambda function writing to the group is in a stack, the note is informational: Lambda created the group, so the stack won’t undo the change.

## Find groups that never expire

The [Waste finder](https://cloudconsole.dev/help/waste-finder) lists log groups that never expire and store a lot, with their monthly cost, and can set 30 days on each. The log groups list marks them with a tip too.

## Permissions

`logs:PutRetentionPolicy` to set a retention and `logs:DeleteRetentionPolicy` for Never expire. Changes need Pro.

## Questions

### How much does log retention save?

CloudWatch Logs bills stored data per GB each month, so a group that never expires costs more every month. The Waste finder shows what each such group costs now; setting a retention stops that growth and removes what is older.

### Will my Terraform plan show a difference?

Yes, if Terraform manages the log group and its code says something else. Change retention_in_days in the code too, or the next apply puts it back.

**Still stuck?**

Email [support@cloudconsole.dev](mailto:support@cloudconsole.dev) with what you tried and any message the app showed. Don’t send access keys or secrets. We reply within two working days.

## Related

- [Read and search CloudWatch Logs](https://cloudconsole.dev/help/logs) – Using the app
- [Find waste: unused resources that cost money](https://cloudconsole.dev/help/waste-finder) – Using the app
- [Costs, forecast and what Cost Explorer charges](https://cloudconsole.dev/help/costs) – Using the app
- [Guardrails: how changes are confirmed](https://cloudconsole.dev/help/guardrails) – Safety & changes

[All help topics →](https://cloudconsole.dev/help/)

---

Source: https://cloudconsole.dev/help/log-retention

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
