Skip to content

Commit bd06669

Browse files
authored
fix(lambda): add instrument handler option to adotInstrumentation to support python lambda functions (#26040)
Small change to add an enum value to AdotLambdaExecWrapper. The python layer for adot requires the path *'/opt/otel-instrument'* which differs from the layer needed for other languages which is *'/opt/otel-handler'*. In the link below in the section **Enable auto-instrumentation for your Lambda function** step 5 requires the *'/opt/otel-instrument'* path. The existing work around is to provide a lambda layer yourself and the appropriate env variable for *AWS_LAMBDA_EXEC_WRAPPER* without using the adotInstrumentation parameters. This fix simplifies dev requirements. [Python Lambda Otel](https://aws-otel.github.io/docs/getting-started/lambda/lambda-python) Closes #24666. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f9a1192 commit bd06669

File tree

14 files changed

+309
-199
lines changed

14 files changed

+309
-199
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "22.0.0",
2+
"version": "32.0.0",
33
"files": {
44
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
55
"source": {

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.assets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "22.0.0",
2+
"version": "32.0.0",
33
"files": {
4-
"47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2": {
4+
"da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86": {
55
"source": {
66
"path": "Stack1.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2.json",
12+
"objectKey": "da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack1.template.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
},
167167
"Environment": {
168168
"Variables": {
169-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
169+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
170170
}
171171
},
172172
"Handler": "index.handler",
@@ -263,7 +263,7 @@
263263
},
264264
"Environment": {
265265
"Variables": {
266-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
266+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
267267
}
268268
},
269269
"Handler": "index.handler",
@@ -360,7 +360,7 @@
360360
},
361361
"Environment": {
362362
"Variables": {
363-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
363+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
364364
}
365365
},
366366
"Handler": "index.handler",
@@ -457,7 +457,7 @@
457457
},
458458
"Environment": {
459459
"Variables": {
460-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
460+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
461461
}
462462
},
463463
"Handler": "index.handler",

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.assets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "22.0.0",
2+
"version": "32.0.0",
33
"files": {
4-
"a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8": {
4+
"a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5": {
55
"source": {
66
"path": "Stack2.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8.json",
12+
"objectKey": "a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/Stack2.template.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
},
170170
"Environment": {
171171
"Variables": {
172-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
172+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
173173
}
174174
},
175175
"Handler": "index.handler",
@@ -266,7 +266,7 @@
266266
},
267267
"Environment": {
268268
"Variables": {
269-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
269+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
270270
}
271271
},
272272
"Handler": "index.handler",
@@ -363,7 +363,7 @@
363363
},
364364
"Environment": {
365365
"Variables": {
366-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
366+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
367367
}
368368
},
369369
"Handler": "index.handler",
@@ -460,7 +460,7 @@
460460
},
461461
"Environment": {
462462
"Variables": {
463-
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
463+
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
464464
}
465465
},
466466
"Handler": "index.handler",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"22.0.0"}
1+
{"version":"32.0.0"}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/integ.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "22.0.0",
2+
"version": "32.0.0",
33
"testCases": {
44
"IntegTest/DefaultTest": {
55
"stacks": [

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-adot.js.snapshot/manifest.json

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "22.0.0",
2+
"version": "32.0.0",
33
"artifacts": {
44
"Stack1.assets": {
55
"type": "cdk:asset-manifest",
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [
@@ -140,6 +140,33 @@
140140
"type": "aws:cdk:logicalId",
141141
"data": "CheckBootstrapVersion"
142142
}
143+
],
144+
"MyFunc6ServiceRoleCDDBC2C6": [
145+
{
146+
"type": "aws:cdk:logicalId",
147+
"data": "MyFunc6ServiceRoleCDDBC2C6",
148+
"trace": [
149+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
150+
]
151+
}
152+
],
153+
"MyFunc6ServiceRoleDefaultPolicyC4D4BF55": [
154+
{
155+
"type": "aws:cdk:logicalId",
156+
"data": "MyFunc6ServiceRoleDefaultPolicyC4D4BF55",
157+
"trace": [
158+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
159+
]
160+
}
161+
],
162+
"MyFunc60D944984": [
163+
{
164+
"type": "aws:cdk:logicalId",
165+
"data": "MyFunc60D944984",
166+
"trace": [
167+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
168+
]
169+
}
143170
]
144171
},
145172
"displayName": "Stack1"
@@ -160,7 +187,7 @@
160187
"validateOnSynth": false,
161188
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
162189
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
163-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8.json",
190+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json",
164191
"requiresBootstrapStackVersion": 6,
165192
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
166193
"additionalDependencies": [
@@ -277,6 +304,33 @@
277304
"type": "aws:cdk:logicalId",
278305
"data": "CheckBootstrapVersion"
279306
}
307+
],
308+
"MyFunc6ServiceRoleCDDBC2C6": [
309+
{
310+
"type": "aws:cdk:logicalId",
311+
"data": "MyFunc6ServiceRoleCDDBC2C6",
312+
"trace": [
313+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
314+
]
315+
}
316+
],
317+
"MyFunc6ServiceRoleDefaultPolicyC4D4BF55": [
318+
{
319+
"type": "aws:cdk:logicalId",
320+
"data": "MyFunc6ServiceRoleDefaultPolicyC4D4BF55",
321+
"trace": [
322+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
323+
]
324+
}
325+
],
326+
"MyFunc60D944984": [
327+
{
328+
"type": "aws:cdk:logicalId",
329+
"data": "MyFunc60D944984",
330+
"trace": [
331+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
332+
]
333+
}
280334
]
281335
},
282336
"displayName": "Stack2"

0 commit comments

Comments
 (0)