0

I'm trying to migrate to the AL2 runtime from go1.x to deploy my Lambda functions but I'm having troubles with how to do so. I use the Serverless Framework for deployment in conjunction with make. Here is the Makefile that I currently use:

go_apps = bin/func1 bin/func2 bin/fun3 bin/% : functions/%.go functions/common.go env GOOS=linux go build -ldflags="-s -w" -o $@ $< functions/common.go build: $(go_apps) clean: rm -rf ./bin deploy: sls deploy --verbose install: build deploy 

Any help would be greatly appreciated


Update: I found this article that should help with migration

I'll report back when I've implemented it and ensures it works as intended


Update 2:

I was able to use SAM local to test my functions in the new AL2 runtime successfully with the help of this AWS sample AL2 implementation with Go. I moved my common.go file to a new repository and built a go module successfully with it (which was then imported to my functions). This is just a start as I have yet to deploy my functions via Serverless but this might be helpful to others in the meantime.

1 Answer 1

0

I found out that you can in fact do a go build with two (or more) files and run/deploy it to an AL2 runtime. Be sure your second file (in my case, common.go) has the functions/structs publicly accessible. Also, make sure you update github.com/aws/aws-lambda-go/lambda to the latest version. And use this github repo sample to help with your serverless template.

This is a sample of my Makefile that is used to deploy to AWS Lambda using the Serverless framework:

go_bootstrap = func1 func2 func3 \ build: for n in $(go_bootstrap); \ do \ echo "$$n"; \ env GOOS=linux go build -o ./build/"$$n"/bootstrap functions/common.go functions/"$$n".go; \ zip -j ./build/zip/"$$n".zip ./build/"$$n"/bootstrap; \ done deploy: sls deploy --verbose install: build deploy 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.