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(cdk-assets): propagate buildSsh flag to docker build #26846

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/aws-lambda/test/code.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,15 @@ describe('code', () => {
const dockerfilePath = 'Dockerfile';
const dockerBuildTarget = 'stage';
const dockerBuildArgs = { arg1: 'val1', arg2: 'val2' };
const dockerBuildSsh = 'default';

// when
new lambda.Function(stack, 'Fn', {
code: lambda.Code.fromAssetImage(path.join(__dirname, 'docker-lambda-handler'), {
file: dockerfilePath,
target: dockerBuildTarget,
buildArgs: dockerBuildArgs,
buildSsh: dockerBuildSsh,
}),
handler: lambda.Handler.FROM_IMAGE,
runtime: lambda.Runtime.FROM_IMAGE,
Expand All @@ -349,9 +351,10 @@ describe('code', () => {
// then
Template.fromStack(stack).hasResource('AWS::Lambda::Function', {
Metadata: {
[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.a8922a1fd787021d071844bc2b1fe3622372bbdfda823528c00983a806ba0e26',
[cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.4d4e274f69ea222694c68ac0cea32b855247d6bdad3074a5987e3a7a907c4745',
[cxapi.ASSET_RESOURCE_METADATA_DOCKERFILE_PATH_KEY]: dockerfilePath,
[cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_ARGS_KEY]: dockerBuildArgs,
[cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_SSH_KEY]: dockerBuildSsh,
[cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_TARGET_KEY]: dockerBuildTarget,
[cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY]: 'Code.ImageUri',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class AssetManifestBuilder {
directory: asset.directoryName,
dockerBuildArgs: asset.dockerBuildArgs,
dockerBuildSecrets: asset.dockerBuildSecrets,
dockerBuildSsh: asset.dockerBuildSsh,
dockerBuildTarget: asset.dockerBuildTarget,
dockerFile: asset.dockerFile,
networkMode: asset.networkMode,
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/core/lib/stack-synthesizers/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export class LegacyStackSynthesizer extends StackSynthesizer implements IReusabl
path: asset.directoryName,
sourceHash: asset.sourceHash,
buildArgs: asset.dockerBuildArgs,
buildSecrets: asset.dockerBuildSecrets,
buildSsh: asset.dockerBuildSsh,
target: asset.dockerBuildTarget,
file: asset.dockerFile,
networkMode: asset.networkMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class ContainerImageBuilder {
tag: localTagName,
buildArgs: source.dockerBuildArgs,
buildSecrets: source.dockerBuildSecrets,
buildSsh: source.dockerBuildSsh,
target: source.dockerBuildTarget,
file: source.dockerFile,
networkMode: source.networkMode,
Expand Down