Skip to content

Commit

Permalink
fix(aws-lambda-python): skip default docker build when image passed (#…
Browse files Browse the repository at this point in the history
…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*
  • Loading branch information
relm923 authored Feb 28, 2022
1 parent 3f49f02 commit 7300f2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/@aws-cdk/aws-lambda-python/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ export class Bundling implements CdkBundlingOptions {
outputDir: outputPath,
});

const defaultImage = DockerImage.fromBuild(path.join(__dirname, '../lib'), {
this.image = image ?? DockerImage.fromBuild(path.join(__dirname, '../lib'), {
buildArgs: {
...props.buildArgs ?? {},
IMAGE: runtime.bundlingImage.image,
},
platform: architecture.dockerPlatform,
});
this.image = image ?? defaultImage;
this.command = ['bash', '-c', chain(bundlingCommands)];
this.environment = props.environment;
}
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda-python/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ test('Bundling a function with custom bundling image', () => {
}),
}));

expect(DockerImage.fromBuild).toHaveBeenCalledTimes(1);
expect(DockerImage.fromBuild).toHaveBeenCalledWith(expect.stringMatching(entry));
});

Expand Down

0 comments on commit 7300f2e

Please sign in to comment.