Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AWS Lambda Container in Go
# Create the working directory
mkdir hello

# Change to the directory
cd hello

# Create the files: main.go and Dockerfile

# Initialize the module in Go
go mod init

# Build the go app for Linux
GOOS=linux go build

# Build the docker image
docker build -t lambdatest .

# Run the docker image
docker run -p 9000:8080 lambdatest

# Send a CURL request with a payload
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"name":"steve"}'

# Should output: "Hello steve!"
# Copy function code
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "hello" ]
package main
import (
type MyEvent struct {
Name string `json:"name"`
func HandleRequest(ctx context.Context, name MyEvent) (string, error) {
return fmt.Sprintf("Hello %s!", name.Name), nil
func main() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment