Skip to content

Commit 7300f2e

Browse files
authored
fix(aws-lambda-python): skip default docker build when image passed (#19143)
#18082 added the ability to pass bundling parameters to `PythonFunction`'s. Currently when the `image` parameters is passed both the passed image and the default image are built even though the default image is not used ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3f49f02 commit 7300f2e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/@aws-cdk/aws-lambda-python/lib/bundling.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ export class Bundling implements CdkBundlingOptions {
7070
outputDir: outputPath,
7171
});
7272

73-
const defaultImage = DockerImage.fromBuild(path.join(__dirname, '../lib'), {
73+
this.image = image ?? DockerImage.fromBuild(path.join(__dirname, '../lib'), {
7474
buildArgs: {
7575
...props.buildArgs ?? {},
7676
IMAGE: runtime.bundlingImage.image,
7777
},
7878
platform: architecture.dockerPlatform,
7979
});
80-
this.image = image ?? defaultImage;
8180
this.command = ['bash', '-c', chain(bundlingCommands)];
8281
this.environment = props.environment;
8382
}

packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ test('Bundling a function with custom bundling image', () => {
211211
}),
212212
}));
213213

214+
expect(DockerImage.fromBuild).toHaveBeenCalledTimes(1);
214215
expect(DockerImage.fromBuild).toHaveBeenCalledWith(expect.stringMatching(entry));
215216
});
216217

0 commit comments

Comments
 (0)