Skip to content

Commit ab806da

Browse files
committed
feat: Support both Lambda APIs in the example TypeScript stack
1 parent 1cceed6 commit ab806da

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env node
22
import * as cdk from "aws-cdk-lib";
33
import { CdkTypeScriptStack } from "../lib/cdk-typescript-stack";
4+
import { CdkTypeScriptLambdaOldApiStack } from "../lib/cdk-typescript-lambda-old-api-stack";
45

56
const app = new cdk.App();
67
new CdkTypeScriptStack(app, "CdkTypeScriptStack", {});
8+
new CdkTypeScriptLambdaOldApiStack(app, "CdkTypeScriptLambdaOldApiStack", {});
79
app.synth();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { StackProps } from "aws-cdk-lib";
2+
import { Construct } from "constructs";
3+
import { Datadog, DatadogProps } from "datadog-cdk-constructs-v2";
4+
import { CdkTypeScriptStackBase } from "./cdk-typescript-stack-base";
5+
6+
export class CdkTypeScriptLambdaOldApiStack extends CdkTypeScriptStackBase {
7+
constructor(scope: Construct, id: string, props?: StackProps) {
8+
super(scope, id, props);
9+
10+
console.log("Instrumenting Lambda Functions in TypeScript stack using the old Datadog Lambda API");
11+
12+
const datadogProps: DatadogProps = {
13+
dotnetLayerVersion: 15,
14+
nodeLayerVersion: 108,
15+
pythonLayerVersion: 89,
16+
extensionLayerVersion: 55,
17+
addLayers: true,
18+
apiKey: process.env.DD_API_KEY,
19+
enableDatadogTracing: true,
20+
enableDatadogASM: true,
21+
flushMetricsToLogs: true,
22+
site: "datadoghq.com",
23+
};
24+
25+
const datadog = new Datadog(this, "Datadog", datadogProps);
26+
27+
datadog.addLambdaFunctions(this.lambdaFunctions);
28+
}
29+
}

examples/typescript-stack/lib/cdk-typescript-stack-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Function } from "aws-cdk-lib/aws-lambda";
66
import { HttpLambdaIntegration } from "aws-cdk-lib/aws-apigatewayv2-integrations";
77
import { Construct } from "constructs";
88

9-
export class CdkTypeScriptStackBase extends Stack {
9+
export abstract class CdkTypeScriptStackBase extends Stack {
1010
protected lambdaFunctions: lambda.Function[];
1111
constructor(scope: Construct, id: string, props?: StackProps) {
1212
super(scope, id, props);

examples/typescript-stack/lib/cdk-typescript-stack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StackProps } from "aws-cdk-lib";
22
import { Construct } from "constructs";
3-
import { Datadog, DatadogProps } from "datadog-cdk-constructs-v2";
3+
import { DatadogLambda, DatadogLambdaProps } from "datadog-cdk-constructs-v2";
44
import { CdkTypeScriptStackBase } from "./cdk-typescript-stack-base";
55

66
export class CdkTypeScriptStack extends CdkTypeScriptStackBase {
@@ -9,7 +9,7 @@ export class CdkTypeScriptStack extends CdkTypeScriptStackBase {
99

1010
console.log("Instrumenting Lambda Functions in TypeScript stack with Datadog");
1111

12-
const datadogProps: DatadogProps = {
12+
const datadogLambdaProps: DatadogLambdaProps = {
1313
dotnetLayerVersion: 15,
1414
nodeLayerVersion: 108,
1515
pythonLayerVersion: 89,
@@ -22,7 +22,7 @@ export class CdkTypeScriptStack extends CdkTypeScriptStackBase {
2222
site: "datadoghq.com",
2323
};
2424

25-
const datadog = new Datadog(this, "Datadog", datadogProps);
25+
const datadog = new DatadogLambda(this, "Datadog", datadogLambdaProps);
2626

2727
datadog.addLambdaFunctions(this.lambdaFunctions);
2828
}

0 commit comments

Comments
 (0)