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): bundling docker image does not exist for Go runtime #9465

Merged
merged 3 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 17 additions & 7 deletions packages/@aws-cdk/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export interface LambdaRuntimeProps {
* @default false
*/
readonly supportsInlineCode?: boolean;

/**
* The Docker image name to be used for bundling in this runtime.
* @default - the latest docker image "amazon/aws-sam-cli-build-image-<runtime>" from https://hub.docker.com/u/amazon
*/
readonly bundlingDockerImage?: string;
}

export enum RuntimeFamily {
Expand Down Expand Up @@ -113,17 +119,23 @@ export class Runtime {
/**
* The .NET Core 2.1 runtime (dotnetcore2.1)
*/
public static readonly DOTNET_CORE_2_1 = new Runtime('dotnetcore2.1', RuntimeFamily.DOTNET_CORE);
public static readonly DOTNET_CORE_2_1 = new Runtime('dotnetcore2.1', RuntimeFamily.DOTNET_CORE, {
bundlingDockerImage: 'lambci/lambda:build-dotnetcore2.1',
});

/**
* The .NET Core 3.1 runtime (dotnetcore3.1)
*/
public static readonly DOTNET_CORE_3_1 = new Runtime('dotnetcore3.1', RuntimeFamily.DOTNET_CORE);
public static readonly DOTNET_CORE_3_1 = new Runtime('dotnetcore3.1', RuntimeFamily.DOTNET_CORE, {
bundlingDockerImage: 'lambci/lambda:build-dotnetcore3.1',
});

/**
* The Go 1.x runtime (go1.x)
*/
public static readonly GO_1_X = new Runtime('go1.x', RuntimeFamily.GO);
public static readonly GO_1_X = new Runtime('go1.x', RuntimeFamily.GO, {
bundlingDockerImage: 'lambci/lambda:build-go1.x',
});

/**
* The Ruby 2.5 runtime (ruby2.5)
Expand Down Expand Up @@ -158,17 +170,15 @@ export class Runtime {

/**
* The bundling Docker image for this runtime.
* Points to the AWS SAM build image for this runtime.
*
* @see https://github.com/awslabs/aws-sam-cli
*/
public readonly bundlingDockerImage: BundlingDockerImage;

constructor(name: string, family?: RuntimeFamily, props: LambdaRuntimeProps = { }) {
this.name = name;
this.supportsInlineCode = !!props.supportsInlineCode;
this.family = family;
this.bundlingDockerImage = BundlingDockerImage.fromRegistry(`amazon/aws-sam-cli-build-image-${name}`);
const imageName = props.bundlingDockerImage ?? `amazon/aws-sam-cli-build-image-${name}`;
this.bundlingDockerImage = BundlingDockerImage.fromRegistry(imageName);

Runtime.ALL.push(this);
}
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-lambda/test/test.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,21 @@ export = testCase({

test.done();
},
'overridde to bundlingDockerImage points to the correct image'(test: Test) {
// GIVEN
const runtime = new lambda.Runtime('my-runtime-name', undefined, {
bundlingDockerImage: 'my-docker-image',
});

// THEN
test.equal(runtime.bundlingDockerImage.image, 'my-docker-image');

test.done();
},
'dotnetcore and go have overridden images'(test: Test) {
test.equal(lambda.Runtime.DOTNET_CORE_3_1.bundlingDockerImage.image, 'lambci/lambda:build-dotnetcore3.1');
test.equal(lambda.Runtime.DOTNET_CORE_2_1.bundlingDockerImage.image, 'lambci/lambda:build-dotnetcore2.1');
test.equal(lambda.Runtime.GO_1_X.bundlingDockerImage.image, 'lambci/lambda:build-go1.x');
test.done();
},
});