Skip to content

Commit

Permalink
chore(lambda-go): fix integ test (aws#17365)
Browse files Browse the repository at this point in the history
The test was still using the old `lambci` image and this makes the integ test fail
apparently. **This currently blocks the build of the repo**.

Adapted Dockerfile now that go is not installed in `/go` anymore.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold authored and TikiTDO committed Feb 21, 2022
1 parent 1341270 commit 21abd00
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
6 changes: 4 additions & 2 deletions packages/@aws-cdk/aws-lambda-go/lib/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# The correct AWS SAM build image based on the runtime of the function will be
# passed as build arg. The default allows to do `docker build .` when testing.
ARG IMAGE=lambci/lambda:build-go1.x
ARG IMAGE=public.ecr.aws/sam/build-go1.x
FROM $IMAGE

# set the GOCACHE
ENV GOPATH=/go
ENV GOCACHE=$GOPATH/.cache/go-build
ENV GOPROXY=direct

# Ensure all users can write to GOPATH
RUN chmod -R 777 $GOPATH
RUN mkdir $GOPATH && \
chmod -R 777 $GOPATH

CMD [ "go" ]
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-go/test/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { spawnSync } from 'child_process';
import * as path from 'path';

beforeAll(() => {
spawnSync('docker', ['build', '--build-arg', 'IMAGE=public.ecr.aws/bitnami/golang:1.15', '-t', 'golang', path.join(__dirname, '../lib')]);
spawnSync('docker', ['build', '-t', 'golang', path.join(__dirname, '../lib')]);
});

test('golang is available', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParameters4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1S3Bucket62A8237E"
"Ref": "AssetParameterse04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820S3Bucket854EE9A9"
},
"S3Key": {
"Fn::Join": [
Expand All @@ -49,7 +49,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1S3VersionKey1C4F3B50"
"Ref": "AssetParameterse04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820S3VersionKey2AD7C6E5"
}
]
}
Expand All @@ -62,7 +62,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1S3VersionKey1C4F3B50"
"Ref": "AssetParameterse04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820S3VersionKey2AD7C6E5"
}
]
}
Expand All @@ -87,17 +87,17 @@
}
},
"Parameters": {
"AssetParameters4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1S3Bucket62A8237E": {
"AssetParameterse04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820S3Bucket854EE9A9": {
"Type": "String",
"Description": "S3 bucket for asset \"4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1\""
"Description": "S3 bucket for asset \"e04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820\""
},
"AssetParameters4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1S3VersionKey1C4F3B50": {
"AssetParameterse04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820S3VersionKey2AD7C6E5": {
"Type": "String",
"Description": "S3 key for asset version \"4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1\""
"Description": "S3 key for asset version \"e04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820\""
},
"AssetParameters4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1ArtifactHashBE683488": {
"AssetParameterse04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820ArtifactHash245320AE": {
"Type": "String",
"Description": "Artifact hash for asset \"4702fc8f2fac1855e6700e59222ef0ebbeaf11eba75c66af9f2e216e312b16b1\""
"Description": "Artifact hash for asset \"e04b349f3d0535498861679603e52edaa01d01ee442f4f665c16e22e5bc81820\""
}
}
}
7 changes: 1 addition & 6 deletions packages/@aws-cdk/aws-lambda-go/test/integ.function.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { App, DockerImage, Stack, StackProps } from '@aws-cdk/core';
import { App, Stack, StackProps } from '@aws-cdk/core';
import { Construct } from 'constructs';
import * as lambda from '../lib';

Expand All @@ -15,11 +15,6 @@ class TestStack extends Stack {
new lambda.GoFunction(this, 'go-handler-docker', {
entry: path.join(__dirname, 'lambda-handler-vendor/cmd/api'),
bundling: {
dockerImage: DockerImage.fromBuild(path.join(__dirname, '../lib'), {
buildArgs: {
IMAGE: 'public.ecr.aws/bitnami/golang:1.16.3-debian-10-r16',
},
}),
forcedDockerBundling: true,
goBuildFlags: ['-mod=readonly', '-ldflags "-s -w"'],
},
Expand Down

0 comments on commit 21abd00

Please sign in to comment.