Skip to content

Commit 47f15a6

Browse files
authored
fix(lambda): Update Python Lambda Adot Lambda layer versions (#26411)
This PR adds the additional versions of the Python Adot for Lambda Layers. I added the versions from 1.13 -1.18 and marked 1.18 as LATEST. The integration and unit tests updated for versions 1.18. Not sure if this fix is maintainable in the long term, if there are ideas on ways to dynamically add additional versions in the future. Exemption Request: This is an update to a class supporting the Lambda Layer versions for Python Adot. New functionality from an integration standpoint does not exist. Closes #26168. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent efb0a4c commit 47f15a6

File tree

8 files changed

+78
-75
lines changed

8 files changed

+78
-75
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "32.0.0",
33
"files": {
4-
"da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86": {
4+
"1e011d502b5efbd34b58f00a70ccf34fb812c6af28ee32ffe796b007503169f1": {
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": "da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json",
12+
"objectKey": "1e011d502b5efbd34b58f00a70ccf34fb812c6af28ee32ffe796b007503169f1.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

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
{
180180
"Ref": "AWS::Region"
181181
},
182-
":901920570463:layer:aws-otel-python-amd64-ver-1-13-0:1"
182+
":901920570463:layer:aws-otel-python-amd64-ver-1-18-0:2"
183183
]
184184
]
185185
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "32.0.0",
33
"files": {
4-
"a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5": {
4+
"45de98e0bad004888e2b3a349cf7b69b966cff9ba6effb99b03e462c69adae21": {
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": "a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json",
12+
"objectKey": "45de98e0bad004888e2b3a349cf7b69b966cff9ba6effb99b03e462c69adae21.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

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
{
183183
"Ref": "AWS::Region"
184184
},
185-
":901920570463:layer:aws-otel-python-amd64-ver-1-13-0:1"
185+
":901920570463:layer:aws-otel-python-amd64-ver-1-18-0:2"
186186
]
187187
]
188188
}

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

+2-56
Original file line numberDiff line numberDiff line change
@@ -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}/da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/1e011d502b5efbd34b58f00a70ccf34fb812c6af28ee32ffe796b007503169f1.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [
@@ -140,33 +140,6 @@
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-
}
170143
]
171144
},
172145
"displayName": "Stack1"
@@ -187,7 +160,7 @@
187160
"validateOnSynth": false,
188161
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
189162
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
190-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json",
163+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/45de98e0bad004888e2b3a349cf7b69b966cff9ba6effb99b03e462c69adae21.json",
191164
"requiresBootstrapStackVersion": 6,
192165
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
193166
"additionalDependencies": [
@@ -304,33 +277,6 @@
304277
"type": "aws:cdk:logicalId",
305278
"data": "CheckBootstrapVersion"
306279
}
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-
}
334280
]
335281
},
336282
"displayName": "Stack2"

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
}
168168
},
169169
"constructInfo": {
170-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
170+
"fqn": "aws-cdk-lib.aws_lambda.Function",
171171
"version": "0.0.0"
172172
}
173173
},
@@ -312,7 +312,7 @@
312312
{
313313
"Ref": "AWS::Region"
314314
},
315-
":901920570463:layer:aws-otel-python-amd64-ver-1-13-0:1"
315+
":901920570463:layer:aws-otel-python-amd64-ver-1-18-0:2"
316316
]
317317
]
318318
}
@@ -338,7 +338,7 @@
338338
}
339339
},
340340
"constructInfo": {
341-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
341+
"fqn": "aws-cdk-lib.aws_lambda.Function",
342342
"version": "0.0.0"
343343
}
344344
},
@@ -501,7 +501,7 @@
501501
}
502502
},
503503
"constructInfo": {
504-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
504+
"fqn": "aws-cdk-lib.aws_lambda.Function",
505505
"version": "0.0.0"
506506
}
507507
},
@@ -664,7 +664,7 @@
664664
}
665665
},
666666
"constructInfo": {
667-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
667+
"fqn": "aws-cdk-lib.aws_lambda.Function",
668668
"version": "0.0.0"
669669
}
670670
},
@@ -827,7 +827,7 @@
827827
}
828828
},
829829
"constructInfo": {
830-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
830+
"fqn": "aws-cdk-lib.aws_lambda.Function",
831831
"version": "0.0.0"
832832
}
833833
},
@@ -1019,7 +1019,7 @@
10191019
}
10201020
},
10211021
"constructInfo": {
1022-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
1022+
"fqn": "aws-cdk-lib.aws_lambda.Function",
10231023
"version": "0.0.0"
10241024
}
10251025
},
@@ -1156,7 +1156,7 @@
11561156
{
11571157
"Ref": "AWS::Region"
11581158
},
1159-
":901920570463:layer:aws-otel-python-amd64-ver-1-13-0:1"
1159+
":901920570463:layer:aws-otel-python-amd64-ver-1-18-0:2"
11601160
]
11611161
]
11621162
}
@@ -1182,7 +1182,7 @@
11821182
}
11831183
},
11841184
"constructInfo": {
1185-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
1185+
"fqn": "aws-cdk-lib.aws_lambda.Function",
11861186
"version": "0.0.0"
11871187
}
11881188
},
@@ -1345,7 +1345,7 @@
13451345
}
13461346
},
13471347
"constructInfo": {
1348-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
1348+
"fqn": "aws-cdk-lib.aws_lambda.Function",
13491349
"version": "0.0.0"
13501350
}
13511351
},
@@ -1508,7 +1508,7 @@
15081508
}
15091509
},
15101510
"constructInfo": {
1511-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
1511+
"fqn": "aws-cdk-lib.aws_lambda.Function",
15121512
"version": "0.0.0"
15131513
}
15141514
},
@@ -1671,7 +1671,7 @@
16711671
}
16721672
},
16731673
"constructInfo": {
1674-
"fqn": "aws-cdk-lib.aws_lambda.FunctionBase",
1674+
"fqn": "aws-cdk-lib.aws_lambda.Function",
16751675
"version": "0.0.0"
16761676
}
16771677
},

packages/aws-cdk-lib/aws-lambda/lib/adot-layers.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,32 @@ export class AdotLambdaLayerPythonSdkVersion extends AdotLambdaLayerVersion {
253253
* The latest layer version available in this CDK version. New versions could
254254
* introduce incompatible changes. Make sure to test them before deploying to production.
255255
*/
256-
public static readonly LATEST = new AdotLambdaLayerPythonSdkVersion('1.13.0');
256+
public static readonly LATEST = new AdotLambdaLayerPythonSdkVersion('1.18.0');
257+
258+
/**
259+
* Version 1.18.0
260+
*/
261+
public static readonly V1_18_0 = new AdotLambdaLayerPythonSdkVersion('1.18.0');
262+
263+
/**
264+
* Version 1.17.0
265+
*/
266+
public static readonly V1_17_0 = new AdotLambdaLayerPythonSdkVersion('1.17.0');
267+
268+
/**
269+
* Version 1.16.0
270+
*/
271+
public static readonly V1_16_0 = new AdotLambdaLayerPythonSdkVersion('1.16.0');
272+
273+
/**
274+
* Version 1.15.0
275+
*/
276+
public static readonly V1_15_0 = new AdotLambdaLayerPythonSdkVersion('1.15.0');
277+
278+
/**
279+
* Version 1.14.0
280+
*/
281+
public static readonly V1_14_0 = new AdotLambdaLayerPythonSdkVersion('1.14.0');
257282

258283
/**
259284
* Version 1.13.0

packages/aws-cdk-lib/aws-lambda/test/adot.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ describe('ADOT Lambda Layer', () => {
3737
});
3838
});
3939

40+
describe('when the Python ADOT version is specified', () => {
41+
42+
let fn: lambda.Function;
43+
44+
beforeEach(() => {
45+
const app = new cdk.App();
46+
const stack = new cdk.Stack(app, 'stack', { env: { region: 'us-west-2' } });
47+
const bucket = new s3.Bucket(stack, 'CodeBucket');
48+
fn = new lambda.Function(stack, 'Function', {
49+
code: lambda.Code.fromBucket(bucket, 'mock_key'),
50+
handler: 'index.handler',
51+
runtime: lambda.Runtime.PYTHON_3_11,
52+
});
53+
});
54+
55+
test('is added properly when the region information is available at synthesis time', () => {
56+
const layerArn = lambda.AdotLambdaLayerPythonSdkVersion.V1_18_0.layerArn(fn.stack, fn.architecture);
57+
58+
expect(layerArn).toEqual(
59+
'arn:aws:lambda:us-west-2:901920570463:layer:aws-otel-python-amd64-ver-1-18-0:2',
60+
);
61+
});
62+
63+
test('is added properly when using "LATEST" version', () => {
64+
const layerArn = lambda.AdotLambdaLayerPythonSdkVersion.LATEST.layerArn(fn.stack, fn.architecture);
65+
66+
expect(layerArn).toEqual(
67+
'arn:aws:lambda:us-west-2:901920570463:layer:aws-otel-python-amd64-ver-1-18-0:2',
68+
);
69+
});
70+
});
71+
4072
describe('when the stack region is not supported', () => {
4173
test('throws error if the region is not supported', () => {
4274
const app = new cdk.App();

0 commit comments

Comments
 (0)