AWS SDK for Go
Developer Guide

Configuring a Lambda Function to Receive Notifications

The following example configures the Lambda function functionName to accept notifications from the resource with the ARN sourceArn.

The first step is to create the session and Lambda client.

package main import ( "flag" "fmt" "os"

Next, we create the structure for the input argument to the AddPermission function.

"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/lambda" ) func addNotification(functionName *string, sourceArn *string) { // Initialize a session

Finally, we call AddPermission and display a message with the result of the call.

SharedConfigState: session.SharedConfigEnable, })) // Create Lambda service client svc := lambda.New(sess, &aws.Config{Region: aws.String("us-west-2")}) permArgs := &lambda.AddPermissionInput{ Action: aws.String("lambda:InvokeFunction"),

See the complete example on GitHub.