github.com/Foodji/aws-lambda-go@v1.20.2/events/README_Cognito_UserPools_PreTokenGen.md (about)

     1  # Sample Function
     2  
     3  The following is a sample Lambda function that receives Amazon Cognito User Pools pre-token-gen event as an input and writes some of the record data to CloudWatch Logs. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
     4  
     5  Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html .
     6  
     7  ```go
     8  package main
     9  
    10  import (
    11      "fmt"
    12  
    13      "github.com/aws/aws-lambda-go/lambda"
    14      "github.com/aws/aws-lambda-go/events"
    15  )
    16  
    17  func handler(event events.CognitoEventUserPoolsPreTokenGen) (events.CognitoEventUserPoolsPreTokenGen, error) {
    18      fmt.Printf("PreTokenGen of user: %s\n", event.UserName)
    19      event.Response.ClaimsOverrideDetails.ClaimsToSuppress = []string{"family_name"}
    20      return event, nil
    21  }
    22  
    23  func main() {
    24    lambda.Start(handler)
    25  }
    26  ```