gov2/workflows/user_pools_and_lambda_triggers/README.md
This example shows how to use AWS SDKs to customize Amazon Cognito authentication behavior. You can configure your Amazon Cognito user pool to automatically invoke AWS Lambda functions at various points in the authentication process, such as before sign-up, during sign-in, and after authentication.
There are three workflows demonstrated by this example:
These workflows are described in more detail in the main README for these examples.
A pre sign-up Lambda trigger is invoked when a user starts the sign-up process and lets your Lambda function take action before Amazon Cognito adds the user to the user pool.
A migrate user Lambda trigger is invoked when a user doesn't exist in the user pool at sign-in with a password. After the Lambda function returns successfully, Amazon Cognito creates the user in the user pool.
A post authentication Lambda trigger is invoked after signing in a user, so you can add custom logic after Amazon Cognito authenticates the user.
For general prerequisites, see the README in the gov2 folder.
This example deploys several resources by using an AWS CloudFormation stack. This stack deploys the following resources:
doc-example-custom-users that has a UserEmail primary key.
This table functions as an external user store.The AWS resources for this example are deployed by using the AWS Cloud Development Kit (AWS CDK).
To install the AWS CDK, follow the instructions in the Developer Guide.
Deploy resources at a command prompt from the .cdk folder:
npm install
cdk deploy
These scenarios can be run with the cmd runner.
go run ./cmd -scenario [auto_confirm migrate_user activity_log]
Delete resources deployed for this example by deleting the stack.
Delete the stack at a command prompt from the .cdk folder:
cdk destroy
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0