Updates the retention policy for new and existing CloudWatch log groups to the specified number of days.
Go to this page and click the Deploy button.
To deploy this via SAM, you need something like this in the CloudFormation template:
AutoSetLogRetention:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:374852340823:applications/auto-set-log-group-retention
SemanticVersion: <enter latest version>
Parameters:
RetentionDays: <defaults to 7>
To do the same via CloudFormation
or the Serverless
framework, you need to first add the following Transform
:
Transform: AWS::Serverless-2016-10-31
For more details, read this post.
RetentionDays
: The number of days to retain logs in CloudWatch Logs for.