Created
March 22, 2022 19:10
-
-
Save percybolmer/2f8409a804ed34c90ceb55aaaa65ffcb to your computer and use it in GitHub Desktop.
The simplest lambda in go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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