/go-al2-example

Example Lambda in Go on provided.al2

Primary LanguageGo

Go-Lambda-AL2

Experimental project for running an AWS Lambda function in Go on provided.al2 runtime.

Local Testing

Method 1: Without custom image

Using Lambda Provided Image

make lambda
docker run -p 9000:8080 -v "$(pwd)/bin/lambda/bootstrap:/var/runtime/bootstrap" public.ecr.aws/lambda/provided:al2 /var/runime/bootstrap

To test event:

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"hello":"world"}'

Method 2: With custom image

docker build -t mytestimg .
docker run -p 9000:8080 mytestimg

To test event:

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"hello":"world"}'

Method 3: Using SAM

sam build
sam local start-lambda

To test event:

curl -XPOST "http://localhost:3001/2015-03-31/functions/goal2/invocations" -d '{"hello":"world"}'

NOTE: URL is different from other methods.

References