One line of code, trace an entire AWS CDK application

Monitoring AWS CDK 2 applications

The Lumigo CDK Constructs for AWS CDK 2 provided via the @lumigo/cdk-constructs-v2 package offer a one-liner approach to monitoring all the Node.js and Python workloads running on AWS Lambda and Amazon ECS that are managed with AWS CDK 2:

import { Lumigo } from '@lumigo/cdk-constructs-v2';
import { App, SecretValue } from 'aws-cdk-lib';

const app = new App();

// Add here stacks and constructs

const lumigo = new Lumigo({
  lumigoToken:SecretValue.unsafePlainText(<lumigo_token>), // Use SecretValue.secretsManager or SecretValue.ssmSecure if you can :-)
lumigo.traceEverything(app, {
  traceEcs: true,  // This activates adding tracing to Amazon ECS task definitions and services as well


The Lumigo construct will go across all the constructs you declare in your AWS CDK 2 App and add Lumigo tracing to Lambda functions using a Node.js or Python runtime, and adding the Lumigo OpenTelemetry distributions for Node.js and Python to your Amazon ECS workloads.

Fine-grained control in terms of which AWS Lambda functions and Amazon ECS workloads is also available; see the Lumigo CDK Constructs repository for detailed documentation.

Monitoring Lambda functions with AWS CDK

When managing AWS Lambda functions with the AWS CDK 1, you have Lumigo trace AWS Lambda functions running on a Node.js or Python runtime by using the Tags AWS CDK functionality to add the lumigo:auto-trace AWS tag:

#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';

class MyLambdaStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const myFunction = new lambda.Function(this, 'MyLambdaFunction', {
        runtime: lambda.Runtime.NODEJS_16_X,
        code: lambda.Code.fromAsset('resources/lambda'),
        handler: 'index.handler',

    // Lumigo will automatically add tracing to the `myFunction` function!
    cdk.Tags.of(myFunction).add('lumigo:auto-trace', 'true');

const app = new cdk.App();
new MyLambdaStack(app, 'MyLambdaStack');

Since the automatic injection is performed by Lumigo after your function is deployed by CloudFormation, the Lumigo layer and the other settings that Lumigo applies to your function will not be part of the output of cdk synth.