github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/terraform-aws-lambda-example/src/lambda.go (about) 1 package main 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/aws/aws-lambda-go/lambda" 8 ) 9 10 type Event struct { 11 ShouldFail bool `json:"ShouldFail"` 12 Echo string `json:"Echo"` 13 } 14 15 // Fails if ShouldFail is `true`, otherwise echos the input. 16 func HandleRequest(ctx context.Context, evnt Event) (string, error) { 17 if evnt.ShouldFail { 18 return "", fmt.Errorf("Failed to handle %#v", evnt) 19 } 20 return evnt.Echo, nil 21 } 22 23 func main() { 24 lambda.Start(HandleRequest) 25 }