Skip to content

Commit c724d27

Browse files
fix(lambda-python-alpha): use function architecture (#18696) (#28449)
With this change, architecture when bundling is inferred from the target architecture of the Lambda function. Closes #18696. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 16a1a62 commit c724d27

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/@aws-cdk/aws-lambda-python-alpha/lib/function.ts

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export class PythonFunction extends Function {
7474
entry,
7575
runtime,
7676
skip: !Stack.of(scope).bundlingRequired,
77+
// define architecture based on the target architecture of the function, possibly overriden in bundling options
78+
architecture: props.architecture,
7779
...props.bundling,
7880
}),
7981
handler: resolvedHandler,

packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
22
import { Template } from 'aws-cdk-lib/assertions';
3-
import { Code, Runtime } from 'aws-cdk-lib/aws-lambda';
3+
import { Code, Runtime, Architecture } from 'aws-cdk-lib/aws-lambda';
44
import * as lambda from 'aws-cdk-lib/aws-lambda';
55
import { AssetHashType, DockerImage, Stack } from 'aws-cdk-lib';
66
import { PythonFunction } from '../lib';
@@ -217,3 +217,17 @@ test('Do not skip bundling when stack requires it', () => {
217217

218218
spy.mockRestore();
219219
});
220+
221+
test('PythonFunction specifying architecture', () => {
222+
new PythonFunction(stack, 'handler', {
223+
entry: path.join(__dirname, 'lambda-handler'),
224+
runtime: Runtime.PYTHON_3_11,
225+
architecture: Architecture.ARM_64,
226+
});
227+
228+
expect(Bundling.bundle).toHaveBeenCalledWith(
229+
expect.objectContaining({
230+
architecture: Architecture.ARM_64,
231+
}),
232+
);
233+
});

0 commit comments

Comments
 (0)