# UserPoolTriggers

Triggers for a user pool.

- Source: [`aws-cognito/lib/user-pool.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cognito/lib/user-pool.ts#L106)
- Type last changed: v2.1.0 · 8 Dec 2021

## Example

```ts
const authChallengeFn = new lambda.Function(this, 'authChallengeFn', {
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'path/to/asset')),
});

const userpool = new cognito.UserPool(this, 'myuserpool', {
  // ...
  lambdaTriggers: {
    createAuthChallenge: authChallengeFn,
    // ...
  },
});

userpool.addTrigger(cognito.UserPoolOperation.USER_MIGRATION, new lambda.Function(this, 'userMigrationFn', {
    runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'path/to/asset')),
}));
```

## Properties

- `createAuthChallenge`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — Creates an authentication challenge.

  **Default:** no trigger configured

- `customEmailSender`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — Amazon Cognito invokes this trigger to send email notifications to users.

  **Default:** no trigger configured

- `customMessage`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A custom Message AWS Lambda trigger.

  **Default:** no trigger configured

- `customSmsSender`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — Amazon Cognito invokes this trigger to send SMS notifications to users.

  **Default:** no trigger configured

- `defineAuthChallenge`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — Defines the authentication challenge.

  **Default:** no trigger configured

- `postAuthentication`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A post-authentication AWS Lambda trigger.

  **Default:** no trigger configured

- `postConfirmation`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A post-confirmation AWS Lambda trigger.

  **Default:** no trigger configured

- `preAuthentication`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A pre-authentication AWS Lambda trigger.

  **Default:** no trigger configured

- `preSignUp`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A pre-registration AWS Lambda trigger.

  **Default:** no trigger configured

- `preTokenGeneration`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A pre-token-generation AWS Lambda trigger.

  **Default:** no trigger configured

- `userMigration`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A user-migration AWS Lambda trigger.

  **Default:** no trigger configured

- `verifyAuthChallengeResponse`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — Verifies the authentication challenge response.

  **Default:** no trigger configured
