Creates a custom resource to control the retention policy of a CloudWatch Logs log group. The log group is created if it doesn't already exist. The policy is removed when `retentionDays` is `undefined` or equal to `Infinity`. Log group can be created in the region that is different from stack region by specifying `logGroupRegion`
import { LogRetention } from 'aws-cdk-lib/aws-logs';Or use the module namespace:
import * as logs from 'aws-cdk-lib/aws-logs';
// logs.LogRetentionConfiguration passed to the constructor as LogRetentionProps.
logGroupNameRequiredstringThe log group name.
retentionRequiredRetentionDaysThe number of days log events are kept in CloudWatch Logs.
logGroupRegionOptionalstringThe region where the log group should be created.
Default: - same region as the stack
logRetentionRetryOptionsOptionalLogRetentionRetryOptionsRetry options for all AWS API calls.
Default: - AWS SDK default retry options
removalPolicyOptionalRemovalPolicyThe removalPolicy for the log group when the stack is deleted.
Default: RemovalPolicy.RETAIN
roleOptionalIRoleThe IAM role for the Lambda function associated with the custom resource.
Default: - A new role is created
Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.
Subscribe to Newsletteraws-logs