-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event types for Cognito PreAuthentication Lambda trigger (#214)
* Add Cognito trigger: PreAuthentication * Add PreAuthentication test event
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Sample Function | ||
|
||
The following is a sample Lambda function that receives Amazon Cognito User Pools pre-authentication 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.) | ||
|
||
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 . | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-lambda-go/lambda" | ||
"github.com/aws/aws-lambda-go/events" | ||
) | ||
|
||
func handler(event events.CognitoEventUserPoolsPreAuthentication) (events.CognitoEventUserPoolsPreAuthentication, error) { | ||
fmt.Printf("PreAuthentication of user: %s\n", event.UserName) | ||
return event, nil | ||
} | ||
|
||
func main() { | ||
lambda.Start(handler) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
events/testdata/cognito-event-userpools-preauthentication.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"version": "1", | ||
"triggerSource": "PreAuthentication_Authentication", | ||
"region": "<region>", | ||
"userPoolId": "<userPoolId>", | ||
"userName": "<userName>", | ||
"callerContext": { | ||
"awsSdkVersion": "<calling aws sdk with version>", | ||
"clientId": "<apps client id>" | ||
}, | ||
"request": { | ||
"userAttributes": { | ||
"email": "<email>" | ||
}, | ||
"validationData": { | ||
"k1": "v1", | ||
"k2": "v2" | ||
} | ||
}, | ||
"response": {} | ||
} |