aws-cdk-lib.aws_logs.LogGroupProps

interface LogGroupProps

LanguageType name
.NETAmazon.CDK.AWS.Logs.LogGroupProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslogs#LogGroupProps
Javasoftware.amazon.awscdk.services.logs.LogGroupProps
Pythonaws_cdk.aws_logs.LogGroupProps
TypeScript (source)aws-cdk-lib » aws_logs » LogGroupProps

Properties for a LogGroup.

Example

declare const vpc: ec2.Vpc;
const kmsKey = new kms.Key(this, 'KmsKey');

// Pass the KMS key in the `encryptionKey` field to associate the key to the log group
const logGroup = new logs.LogGroup(this, 'LogGroup', {
  encryptionKey: kmsKey,
});

// Pass the KMS key in the `encryptionKey` field to associate the key to the S3 bucket
const execBucket = new s3.Bucket(this, 'EcsExecBucket', {
  encryptionKey: kmsKey,
});

const cluster = new ecs.Cluster(this, 'Cluster', {
  vpc,
  executeCommandConfiguration: {
    kmsKey,
    logConfiguration: {
      cloudWatchLogGroup: logGroup,
      cloudWatchEncryptionEnabled: true,
      s3Bucket: execBucket,
      s3EncryptionEnabled: true,
      s3KeyPrefix: 'exec-command-output',
    },
    logging: ecs.ExecuteCommandLogging.OVERRIDE,
  },
});

Properties

NameTypeDescription
dataProtectionPolicy?DataProtectionPolicyData Protection Policy for this log group.
encryptionKey?IKeyThe KMS customer managed key to encrypt the log group with.
logGroupName?stringName of the log group.
removalPolicy?RemovalPolicyDetermine the removal policy of this log group.
retention?RetentionDaysHow long, in days, the log contents will be retained.

dataProtectionPolicy?

Type: DataProtectionPolicy (optional, default: no data protection policy)

Data Protection Policy for this log group.


encryptionKey?

Type: IKey (optional, default: Server-side encrpytion managed by the CloudWatch Logs service)

The KMS customer managed key to encrypt the log group with.


logGroupName?

Type: string (optional, default: Automatically generated)

Name of the log group.


removalPolicy?

Type: RemovalPolicy (optional, default: RemovalPolicy.Retain)

Determine 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.


retention?

Type: RetentionDays (optional, default: RetentionDays.TWO_YEARS)

How long, in days, the log contents will be retained.

To retain all logs, set this value to RetentionDays.INFINITE.