Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created March 22, 2022 19:10
Show Gist options
  • Save percybolmer/2f8409a804ed34c90ceb55aaaa65ffcb to your computer and use it in GitHub Desktop.
Save percybolmer/2f8409a804ed34c90ceb55aaaa65ffcb to your computer and use it in GitHub Desktop.
The simplest lambda in go
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
// Event is the Input Payload representation
type Event struct {
Name string `json:"name"`
}
// Our Lambda function
// Output Whatever you want, error or str, or struct and error etc.
func lambdaHandler(event Event) (string, error) {
// Worlds simplest Lambda, Concatinate Event Name with Hello
output := fmt.Sprintf("Hello From Lambda %s", event.Name)
return output, nil
}
func main() {
// Start the lambda handler
lambda.Start(lambdaHandler)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment