Menu

CloudWatch Logs retention policy for the whole account
📰

CloudWatch Logs retention policy for the whole account

DEV Community: aws·Sascha Mirow-Stanitzok·3 days ago
#nJ8PQgYy
#devtoaws#devto#dev#retention#policy
Reading 0:00
15s threshold

A CloudWatch Logs retention policy is one of those settings nobody thinks about on the first deployment. Every Lambda function writes logs, and CloudWatch keeps them forever by default. After a few years of Serverless you end up with hundreds of log groups, and half of them belong to functions that no longer exist.

Since November 9, 2026, you can fix that centrally. An account-level retention policy defines how long logs stay in all log groups or in a selected subset. That sounds like a checkbox in the console. However, there is one detail in it that can delete data without warning. In this article I show you how the rules work, how to roll them out safely with a dry run, and how to manage them as code with AWS CDK.

In short

CloudWatch Logs can now set retention through policies for the whole account or for prefixes such as /aws/lambda. When several policies match, the longest one wins.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.