From daf2df4dc97560dbcaa0d274a5315e836813c095 Mon Sep 17 00:00:00 2001 From: HugeIRL <38887481+HugeIRL@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:18:58 -0500 Subject: [PATCH 1/4] Rename binary to bootstrap --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c8bdad4..dfdad3a 100644 --- a/Makefile +++ b/Makefile @@ -25,17 +25,17 @@ endif build: handler.zip -handler.zip: lambda/handler +handler.zip: bootstrap zip -9 -v -j $@ "$<" -lambda/handler: lambda/main.go +bootstrap: lambda/main.go docker run \ --env GOCACHE=/go/cache \ --user $(USER) \ --volume $(PWD):/app \ --workdir /app \ --rm golang:1.19 \ - go build -ldflags="$(LD_FLAGS)" -buildvcs="$(BUILDVSC_FLAG)" -o lambda/handler ./lambda + go build -ldflags="$(LD_FLAGS)" -buildvcs="$(BUILDVSC_FLAG)" -o bootstrap ./lambda lambda-sync: handler.zip aws s3 sync \ From c8684e88c7810f1b96e4daa02264b61e330389fe Mon Sep 17 00:00:00 2001 From: HugeIRL <38887481+HugeIRL@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:19:36 -0500 Subject: [PATCH 2/4] Added lambda.norpc tag --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dfdad3a..7ee7415 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ bootstrap: lambda/main.go --volume $(PWD):/app \ --workdir /app \ --rm golang:1.19 \ - go build -ldflags="$(LD_FLAGS)" -buildvcs="$(BUILDVSC_FLAG)" -o bootstrap ./lambda + go build -ldflags="$(LD_FLAGS)" -buildvcs="$(BUILDVSC_FLAG)" -tags lambda.norpc -o bootstrap ./lambda lambda-sync: handler.zip aws s3 sync \ From 042c7a888b0dd066643ddcb7d5709f7d800627ee Mon Sep 17 00:00:00 2001 From: HugeIRL <38887481+HugeIRL@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:20:44 -0500 Subject: [PATCH 3/4] Changed runtime to provided.al2 --- template.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/template.yaml b/template.yaml index 44ee2c9..ab45a5e 100644 --- a/template.yaml +++ b/template.yaml @@ -190,8 +190,10 @@ Resources: Role: !If [ CreateRole, !GetAtt ExecutionRole.Arn, !Ref AutoscalingLambdaExecutionRole ] PermissionsBoundary: !If [ SetRolePermissionsBoundaryARN, !Ref RolePermissionsBoundaryARN, !Ref "AWS::NoValue" ] Timeout: 120 - Handler: handler - Runtime: go1.x + Handler: bootstrap + Runtime: provided.al2 + Architectures: + - x86_64 MemorySize: 128 Environment: Variables: From 95cc87c968af60ed93c2be1a650dfec7f4d9efc8 Mon Sep 17 00:00:00 2001 From: HugeIRL <38887481+HugeIRL@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:21:47 -0500 Subject: [PATCH 4/4] Set CGO_ENABLED to 0 --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7ee7415..c9b69e1 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ clean: LAMBDA_S3_BUCKET := buildkite-aws-stack-lox LAMBDA_S3_BUCKET_PATH := / +export CGO_ENABLED := 0 ifdef BUILDKITE_BUILD_NUMBER LD_FLAGS := -s -w -X version.Build=$(BUILDKITE_BUILD_NUMBER) @@ -31,6 +32,7 @@ handler.zip: bootstrap bootstrap: lambda/main.go docker run \ --env GOCACHE=/go/cache \ + --env CGO_ENABLED \ --user $(USER) \ --volume $(PWD):/app \ --workdir /app \