Registry /
aws / datadog-cdk-constructs-v2
Install & Compatibility
Where this runs
tested against v4.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 361.6MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 17.4s · import 0.000s · 362MB
399MB installed
● package 399MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
DatadogLambda
✓ from datadog_cdk_constructs_v2 import DatadogLambda
✗ from datadog_cdk_constructs_v2 import Datadog
DatadogECSFargate
✓ from datadog_cdk_constructs_v2 import DatadogECSFargate
DatadogStepFunctions
✓ from datadog_cdk_constructs_v2 import DatadogStepFunctions
This quickstart demonstrates how to create a simple AWS Lambda function and apply the Datadog CDK construct to instrument it for monitoring. Before deploying, ensure you have your AWS credentials configured and the `DD_API_KEY` and `DD_APP_KEY` environment variables set. Replace `datadoghq.com` with your specific Datadog site if needed. This example uses a Python 3.9 runtime, which is generally compatible with the latest Datadog layers.
import os
from aws_cdk import App, Stack, Environment
from aws_cdk import aws_lambda as _lambda
from constructs import Construct
from datadog_cdk_constructs_v2 import Datadog
class MyDatadogStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# Define a simple Lambda function
my_lambda = _lambda.Function(
self, "MyDatadogFunction",
runtime=_lambda.Runtime.PYTHON_3_9, # Python 3.9+ recommended for latest layers
handler="app.handler",
code=_lambda.Code.from_inline(
"""import json
import os
def handler(event, context):
print('Hello from Lambda!')
# Simulate some work for traces/metrics
if os.environ.get('DD_TRACE_ENABLED') == 'true':
import datadog_lambda.trigger
return {
'statusCode': 200,
'body': json.dumps('Success')
}"""),
)
# Apply Datadog integration to the Lambda function
datadog = Datadog(self, "Datadog",
datadog_api_key=os.environ.get("DD_API_KEY", ""), # Required
datadog_app_key=os.environ.get("DD_APP_KEY", ""), # Recommended for full features (e.g., custom metrics)
datadog_site="datadoghq.com", # Or 'datadoghq.eu', 'us3.datadoghq.com', etc.
# Optional configurations:
# enable_lambda_metric_collection=True,
# enable_tracing=True,
# enable_forwarder=True, # For log collection
# add_extension=True, # Use Datadog Lambda Extension
# service="my-lambda-service",
# env="prod",
# version="1.0.0"
)
datadog.add_lambda_functions([my_lambda])
app = App()
MyDatadogStack(app, "DatadogIntegrationStack",
env=Environment(account=os.environ.get("CDK_DEFAULT_ACCOUNT"),
region=os.environ.get("CDK_DEFAULT_REGION"))
)
app.synth()
Debug
Known issues
breakingMigration from `datadog-cdk-constructs` (v1) to `datadog-cdk-constructs-v2` requires significant code changes. This package is explicitly designed for AWS CDK v2 (`aws-cdk-lib`) and is not compatible with CDK v1 (`@aws-cdk/core`). The import paths and construct signatures have changed.fixEnsure your project is using `aws-cdk-lib` (CDK v2) and update all `datadog_cdk_constructs` imports to `datadog_cdk_constructs_v2`. Refer to the official migration guide if transitioning from a CDK v1 project.
affects: All versions
gotchaIncorrect or missing Datadog API/APP keys, or an incorrect `datadog_site` can lead to no metrics, traces, or logs appearing in Datadog. These are crucial for proper integration.fixVerify that `DD_API_KEY` and `DD_APP_KEY` environment variables are correctly set during deployment, or passed directly to the `Datadog` construct. Confirm `datadog_site` (e.g., `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`) matches your Datadog organization's region.
affects: All versions
deprecatedThe `enableDatadogASM` property has been deprecated in favor of `datadogAppSecMode` for configuring Application Security Monitoring (ASM).fixUpdate your `Datadog` construct properties. Replace `enableDatadogASM=True` with `datadogAppSecMode='auto'` or another desired mode (e.g., `'iast'` or `'full'`). Set to `None` to disable. Check the latest documentation for available `datadogAppSecMode` values.
affects: v2-3.3.0 and newer
gotchaLambda functions deployed with Python runtimes earlier than 3.9, or Node.js runtimes earlier than 16, may experience issues with newer Datadog layers or extensions, potentially leading to deployment failures or runtime errors.fixEnsure your Lambda function runtimes are compatible with the latest Datadog layers. Datadog generally supports current and recent LTS runtimes. Upgrade your Lambda functions to Python 3.9+ or Node.js 16+ where possible, or explicitly configure older Datadog layer versions if necessary.
affects: All versions
Upgrade
Version history
4.1.0latest on PyPI · released May 15, 2026
Audit
Dependencies
aws-cdk-librequiredCore dependency for building AWS CDK v2 applications. Python 3.9+ is required for the construct.
constructsrequiredRequired by AWS CDK v2.