Creating the Lambda function

To begin creating the Lambda function, follow the given steps:

  1. Create a new project with the following structure:

  1. We will use the easiest Hello world example. The function folder contains a Go-based Lambda function that displays a simple message:
package mainimport "github.com/aws/aws-lambda-go/lambda"func handler() (string, error) {  return "First Lambda function with Terraform", nil}func main() {  lambda.Start(handler)}
  1. You can build a Linux-based binary and generate a deployment package with the following commands:
GOOS=linux go build -o main main.gozip deployment.zip main
  1. Now that the function code is ...

Get Hands-On Serverless Applications with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.