Displaying Information about All Lambda Functions - AWS SDK for Go (version 1)

We announced the upcoming end-of-support for AWS SDK for Go V1. We recommend that you migrate to AWS SDK for Go V2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.

Displaying Information about All Lambda Functions

First import the packages we use in this example.

import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/lambda" "fmt" "os" )

Next, create the session and Lambda client.

sess := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, })) svc := lambda.New(sess, &aws.Config{Region: aws.String("us-west-2")})

Next, call ListFunctions and exit if there is an error.

result, err := svc.ListFunctions(nil) if err != nil { fmt.Println("Cannot list functions") os.Exit(0) }

Finally, display the names and descriptions of the Lambda functions.

fmt.Println("Functions:") for _, f := range result.Functions { fmt.Println("Name: " + aws.StringValue(f.FunctionName)) fmt.Println("Description: " + aws.StringValue(f.Description)) fmt.Println("") }

See the complete example on GitHub.