AWS Fundamentals Logo
AWS Fundamentals

Amazon CloudWatch Logs

24 CDK constructs available in aws-cdk-lib/aws-logs

import * as logs from 'aws-cdk-lib/aws-logs';

L2 Constructs9

Higher-level abstractions with sensible defaults and convenience methods.

CrossAccountDestination

L2

A new CloudWatch Logs Destination for use in cross-account scenarios. CrossAccountDestinations are used to subscribe a Kinesis stream in a different account to a CloudWatch Subscription. For cross-account scenarios, you need to manually create a `CrossAccountDestination` in the destination account. The integration classes in the `aws-cdk-lib/aws-logs-destinations` package (such as `KinesisDestination`) only handle same-account scenarios and do not automatically create `CrossAccountDestination` for cross-account usage.

LogGroup

L2

Define a CloudWatch Log Group.

LogRetention

L2

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`

LogStream

L2

Define a Log Stream in a Log Group.

MetricFilter

L2

A filter that extracts information from CloudWatch Logs and emits to CloudWatch Metrics.

QueryDefinition

L2

Define a query definition for CloudWatch Logs Insights.

ResourcePolicy

L2

Resource Policy for CloudWatch Log Groups. Policies define the operations that are allowed on this resource. You almost never need to define this construct directly. All AWS resources that support resource policies have a method called `addToResourcePolicy()`, which will automatically create a new resource policy if one doesn't exist yet, otherwise it will add to the existing policy. Prefer to use `addToResourcePolicy()` instead.

SubscriptionFilter

L2

A new Subscription on a CloudWatch log group.

Transformer

L2

Represent the L2 construct for the AWS::Logs::Transformer CloudFormation resource.

L1 Constructs15

Direct CloudFormation resource mappings. One-to-one with CloudFormation resource types.

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter

Quick Facts

L2 Constructs9
L1 Constructs15
Moduleaws-cdk-lib/aws-logs