Define a CloudWatch Log Group.
import { LogGroup } from 'aws-cdk-lib/aws-logs';Or use the module namespace:
import * as logs from 'aws-cdk-lib/aws-logs';
// logs.LogGroupConfiguration passed to the constructor as LogGroupProps.
dataProtectionPolicyOptionalDataProtectionPolicyData Protection Policy for this log group.
Default: - no data protection policy
deletionProtectionEnabledOptionalbooleanIndicates whether deletion protection is enabled for this log group. When enabled, deletion protection blocks all deletion operations until it is explicitly disabled.
Default: false
encryptionKeyOptionalIKeyRefThe KMS customer managed key to encrypt the log group with.
Default: Server-side encryption managed by the CloudWatch Logs service
fieldIndexPoliciesOptionalFieldIndexPolicy[]Field Index Policies for this log group.
Default: - no field index policies for this log group.
logGroupClassOptionalLogGroupClassThe class of the log group. Possible values are: STANDARD and INFREQUENT_ACCESS. INFREQUENT_ACCESS class provides customers a cost-effective way to consolidate logs which supports querying using Logs Insights. The logGroupClass property cannot be changed once the log group is created.
Default: LogGroupClass.STANDARD
logGroupNameOptionalstringName of the log group.
Default: Automatically generated
removalPolicyOptionalRemovalPolicyDetermine the removal policy of this log group. Normally you want to retain the log group so you can diagnose issues from logs even after a deployment that no longer includes the log group. In that case, use the normal date-based retention policy to age out your logs.
Default: RemovalPolicy.Retain
retentionOptionalRetentionDaysHow long, in days, the log contents will be retained. To retain all logs, set this value to RetentionDays.INFINITE.
Default: RetentionDays.TWO_YEARS
Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.
Subscribe to Newsletteraws-logs