Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lambda-python-alpha): use function architecture (#18696) #28449

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(lambda-python-alpha): use function architecture (#18696)
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*
  • Loading branch information
lucacucchetti authored and Luca Cucchetti committed Dec 21, 2023
commit 95201254e21cb83c31309baf3db17d7b98841c53
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-lambda-python-alpha/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export class PythonFunction extends Function {
entry,
runtime,
skip: !Stack.of(scope).bundlingRequired,
// define architecture based on the target architecture of the function, possibly overriden in bundling options
architecture: props.architecture,
...props.bundling,
}),
handler: resolvedHandler,
Expand Down
16 changes: 15 additions & 1 deletion packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import { Template } from 'aws-cdk-lib/assertions';
import { Code, Runtime } from 'aws-cdk-lib/aws-lambda';
import { Code, Runtime, Architecture } from 'aws-cdk-lib/aws-lambda';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { AssetHashType, DockerImage, Stack } from 'aws-cdk-lib';
import { PythonFunction } from '../lib';
Expand Down Expand Up @@ -217,3 +217,17 @@ test('Do not skip bundling when stack requires it', () => {

spy.mockRestore();
});

test('PythonFunction specifying architecture', () => {
new PythonFunction(stack, 'handler', {
entry: path.join(__dirname, 'lambda-handler'),
runtime: Runtime.PYTHON_3_11,
architecture: Architecture.ARM_64,
});

expect(Bundling.bundle).toHaveBeenCalledWith(
expect.objectContaining({
architecture: Architecture.ARM_64,
}),
);
});
Loading