Skip to content

Commit 04e34b0

Browse files
committed
fix cdk issue
1 parent c65a23e commit 04e34b0

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

integration-tests/lib/stacks/base-stack.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export class BaseStack extends cdk.Stack {
1616
constructor(scope: Construct, id: string, props: cdk.StackProps) {
1717
super(scope, id, props);
1818

19+
// Get layers once for the entire stack
20+
const extensionLayer = getExtensionLayer(this);
21+
const node20Layer = getNode20Layer(this);
22+
const python313Layer = getPython313Layer(this);
23+
const java21Layer = getJava21Layer(this);
24+
const dotnet8Layer = getDotnet8Layer(this);
25+
1926
// Node.js Lambda
2027
const nodeFunctionName = `${id}-node-lambda`;
2128
const nodeFunction = new lambda.Function(this, nodeFunctionName, {
@@ -35,8 +42,8 @@ export class BaseStack extends cdk.Stack {
3542
logGroup: createLogGroup(this, nodeFunctionName)
3643
});
3744
nodeFunction.addToRolePolicy(defaultDatadogSecretPolicy);
38-
nodeFunction.addLayers(getExtensionLayer(this));
39-
nodeFunction.addLayers(getNode20Layer(this));
45+
nodeFunction.addLayers(extensionLayer);
46+
nodeFunction.addLayers(node20Layer);
4047

4148
// Python Lambda
4249
const pythonFunctionName = `${id}-python-lambda`;
@@ -60,8 +67,8 @@ export class BaseStack extends cdk.Stack {
6067
logGroup: createLogGroup(this, pythonFunctionName)
6168
});
6269
pythonFunction.addToRolePolicy(defaultDatadogSecretPolicy);
63-
pythonFunction.addLayers(getExtensionLayer(this));
64-
pythonFunction.addLayers(getPython313Layer(this));
70+
pythonFunction.addLayers(extensionLayer);
71+
pythonFunction.addLayers(python313Layer);
6572

6673
// Java Lambda
6774
const javaFunctionName = `${id}-java-lambda`;
@@ -82,8 +89,8 @@ export class BaseStack extends cdk.Stack {
8289
logGroup: createLogGroup(this, javaFunctionName)
8390
});
8491
javaFunction.addToRolePolicy(defaultDatadogSecretPolicy);
85-
javaFunction.addLayers(getExtensionLayer(this));
86-
javaFunction.addLayers(getJava21Layer(this));
92+
javaFunction.addLayers(extensionLayer);
93+
javaFunction.addLayers(java21Layer);
8794

8895
// .NET Lambda
8996
const dotnetFunctionName = `${id}-dotnet-lambda`;
@@ -103,7 +110,7 @@ export class BaseStack extends cdk.Stack {
103110
logGroup: createLogGroup(this, dotnetFunctionName)
104111
});
105112
dotnetFunction.addToRolePolicy(defaultDatadogSecretPolicy);
106-
dotnetFunction.addLayers(getExtensionLayer(this));
107-
dotnetFunction.addLayers(getDotnet8Layer(this));
113+
dotnetFunction.addLayers(extensionLayer);
114+
dotnetFunction.addLayers(dotnet8Layer);
108115
}
109116
}

integration-tests/lib/stacks/otlp-stack.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export class OtlpStack extends cdk.Stack {
1212
constructor(scope: Construct, id: string, props: cdk.StackProps) {
1313
super(scope, id, props);
1414

15+
// Get extension layer once for the entire stack
16+
const extensionLayer = getExtensionLayer(this);
17+
1518
// Node.js Lambda
1619
const nodeFunctionName = `${id}-node-lambda`;
1720
const nodeFunction = new lambda.Function(this, nodeFunctionName, {
@@ -33,7 +36,7 @@ export class OtlpStack extends cdk.Stack {
3336
logGroup: createLogGroup(this, nodeFunctionName)
3437
});
3538
nodeFunction.addToRolePolicy(defaultDatadogSecretPolicy);
36-
nodeFunction.addLayers(getExtensionLayer(this));
39+
nodeFunction.addLayers(extensionLayer);
3740

3841
// Python Lambda
3942
const pythonFunctionName = `${id}-python-lambda`;
@@ -56,7 +59,7 @@ export class OtlpStack extends cdk.Stack {
5659
logGroup: createLogGroup(this, pythonFunctionName)
5760
});
5861
pythonFunction.addToRolePolicy(defaultDatadogSecretPolicy);
59-
pythonFunction.addLayers(getExtensionLayer(this));
62+
pythonFunction.addLayers(extensionLayer);
6063

6164
// Java Lambda
6265
const javaFunctionName = `${id}-java-lambda`;
@@ -79,7 +82,7 @@ export class OtlpStack extends cdk.Stack {
7982
logGroup: createLogGroup(this, javaFunctionName)
8083
});
8184
javaFunction.addToRolePolicy(defaultDatadogSecretPolicy);
82-
javaFunction.addLayers(getExtensionLayer(this));
85+
javaFunction.addLayers(extensionLayer);
8386

8487
// .NET Lambda
8588
const dotnetFunctionName = `${id}-dotnet-lambda`;
@@ -102,6 +105,6 @@ export class OtlpStack extends cdk.Stack {
102105
logGroup: createLogGroup(this, dotnetFunctionName)
103106
});
104107
dotnetFunction.addToRolePolicy(defaultDatadogSecretPolicy);
105-
dotnetFunction.addLayers(getExtensionLayer(this));
108+
dotnetFunction.addLayers(extensionLayer);
106109
}
107110
}

0 commit comments

Comments
 (0)