Skip to content
v2.278.0

UserPoolTriggers Struct ​

Triggers for a user pool.

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')),
}));
python
auth_challenge_fn = lambda_.Function(self, "authChallengeFn",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "path/to/asset"))
)

userpool = cognito.UserPool(self, "myuserpool",
    # ...
    lambda_triggers=cognito.UserPoolTriggers(
        create_auth_challenge=auth_challenge_fn
    )
)

userpool.add_trigger(cognito.UserPoolOperation.USER_MIGRATION, lambda_.Function(self, "userMigrationFn",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "path/to/asset"))
))
java
Function authChallengeFn = Function.Builder.create(this, "authChallengeFn")
        .runtime(Runtime.NODEJS_LATEST)
        .handler("index.handler")
        .code(Code.fromAsset(join(__dirname, "path/to/asset")))
        .build();

UserPool userpool = UserPool.Builder.create(this, "myuserpool")
        // ...
        .lambdaTriggers(UserPoolTriggers.builder()
                .createAuthChallenge(authChallengeFn)
                .build())
        .build();

userpool.addTrigger(UserPoolOperation.USER_MIGRATION, Function.Builder.create(this, "userMigrationFn")
        .runtime(Runtime.NODEJS_LATEST)
        .handler("index.handler")
        .code(Code.fromAsset(join(__dirname, "path/to/asset")))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var authChallengeFn = new Function(this, "authChallengeFn", new FunctionProps {
    Runtime = Runtime.NODEJS_LATEST,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "path/to/asset"))
});

var userpool = new UserPool(this, "myuserpool", new UserPoolProps {
    // ...
    LambdaTriggers = new UserPoolTriggers {
        CreateAuthChallenge = authChallengeFn
    }
});

userpool.AddTrigger(UserPoolOperation.USER_MIGRATION, new Function(this, "userMigrationFn", new FunctionProps {
    Runtime = Runtime.NODEJS_LATEST,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "path/to/asset"))
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
authChallengeFn := lambda.NewFunction(this, jsii.String("authChallengeFn"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("path/to/asset"))),
})

userpool := cognito.NewUserPool(this, jsii.String("myuserpool"), &UserPoolProps{
	// ...
	LambdaTriggers: &UserPoolTriggers{
		CreateAuthChallenge: authChallengeFn,
	},
})

userpool.AddTrigger(cognito.UserPoolOperation_USER_MIGRATION(), lambda.NewFunction(this, jsii.String("userMigrationFn"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_*FromAsset(path.join(__dirname, jsii.String("path/to/asset"))),
}))

Properties ​

createAuthChallengeoptionalIFunctioncreate_auth_challengeoptionalIFunctioncreateAuthChallengeoptionalIFunctionCreateAuthChallengeoptionalIFunctionCreateAuthChallengeoptionalIFunction #
Creates an authentication challenge.

Default: no trigger configured

customEmailSenderoptionalIFunctioncustom_email_senderoptionalIFunctioncustomEmailSenderoptionalIFunctionCustomEmailSenderoptionalIFunctionCustomEmailSenderoptionalIFunction #
Amazon Cognito invokes this trigger to send email notifications to users.

Default: no trigger configured

customMessageoptionalIFunctioncustom_messageoptionalIFunctioncustomMessageoptionalIFunctionCustomMessageoptionalIFunctionCustomMessageoptionalIFunction #
A custom Message AWS Lambda trigger.

Default: no trigger configured

customSmsSenderoptionalIFunctioncustom_sms_senderoptionalIFunctioncustomSmsSenderoptionalIFunctionCustomSmsSenderoptionalIFunctionCustomSmsSenderoptionalIFunction #
Amazon Cognito invokes this trigger to send SMS notifications to users.

Default: no trigger configured

defineAuthChallengeoptionalIFunctiondefine_auth_challengeoptionalIFunctiondefineAuthChallengeoptionalIFunctionDefineAuthChallengeoptionalIFunctionDefineAuthChallengeoptionalIFunction #
Defines the authentication challenge.

Default: no trigger configured

postAuthenticationoptionalIFunctionpost_authenticationoptionalIFunctionpostAuthenticationoptionalIFunctionPostAuthenticationoptionalIFunctionPostAuthenticationoptionalIFunction #
A post-authentication AWS Lambda trigger.

Default: no trigger configured

postConfirmationoptionalIFunctionpost_confirmationoptionalIFunctionpostConfirmationoptionalIFunctionPostConfirmationoptionalIFunctionPostConfirmationoptionalIFunction #
A post-confirmation AWS Lambda trigger.

Default: no trigger configured

preAuthenticationoptionalIFunctionpre_authenticationoptionalIFunctionpreAuthenticationoptionalIFunctionPreAuthenticationoptionalIFunctionPreAuthenticationoptionalIFunction #
A pre-authentication AWS Lambda trigger.

Default: no trigger configured

preSignUpoptionalIFunctionpre_sign_upoptionalIFunctionpreSignUpoptionalIFunctionPreSignUpoptionalIFunctionPreSignUpoptionalIFunction #
A pre-registration AWS Lambda trigger.

Default: no trigger configured

preTokenGenerationoptionalIFunctionpre_token_generationoptionalIFunctionpreTokenGenerationoptionalIFunctionPreTokenGenerationoptionalIFunctionPreTokenGenerationoptionalIFunction #
A pre-token-generation AWS Lambda trigger.

Default: no trigger configured

userMigrationoptionalIFunctionuser_migrationoptionalIFunctionuserMigrationoptionalIFunctionUserMigrationoptionalIFunctionUserMigrationoptionalIFunction #
A user-migration AWS Lambda trigger.

Default: no trigger configured

verifyAuthChallengeResponseoptionalIFunctionverify_auth_challenge_responseoptionalIFunctionverifyAuthChallengeResponseoptionalIFunctionVerifyAuthChallengeResponseoptionalIFunctionVerifyAuthChallengeResponseoptionalIFunction #
Verifies the authentication challenge response.

Default: no trigger configured