My step:
- I created user by calling the AdminCreateUser API.
- I use my custom login form to do the first login
- I change password (because I'm in FORCE_PASSWORD_CHANGE status) Now the user is CONFIRMED
- Trigger doesn't fire.
My step:
Cognito does not trigger post confirm when the user is created with adminCreateUser
or manually from Cognito dashboard.
I am looking for the answer to this as well and I found this in the official documentation:-
You create custom workflows by assigning AWS Lambda functions to user pool triggers. When you use the AdminCreateUser API action, Amazon Cognito invokes the function that is assigned to the pre sign-up trigger. When Amazon Cognito invokes this function, it passes a JSON payload, which the function receives as input.
So basically we need to attach the lambda function to the pre sign-up trigger if we are using the AdminCreateUser API action. Haven't checked if it works. Confirmation would be great!
Update:-
I tried it out myself and it does trigger the pre sign-up lambda function. So there's the confirmation!
As the name suggests, it is post "confirmation" trigger. The user needs to confirm the email belongs to him/her. This is done by entering the OTP that cognito sends to the given email address. Once the user enters that OTP, the email address is confirmed and post confirmation trigger fires.
Do Use the hosted UI's "Signup" link to create the account
Do Not Use Cognito service's in-built user creation page. Use Admin API
I believe Ragav's answer is the closest one but missing some extra information. For pre-signup triggers, you run the risk that Cognito denies the registration after you already synced the user to the database. So keep the syncing in the Post-Confirmation trigger.
Add a pre-signup trigger that only listens for "AdminCreateNewUser" type of events, since these are the edge case anyways, and then you can safely add these users to the DB since Cognito won't give any validation problems afterwards for these specific users.
This is the event that the pre-signup trigger passes:
{
"version": "1",
"region": "us-east-1",
"userPoolId": "us-east-1_xxxxxxxx",
"userName": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"callerContext": {
"awsSdkVersion": "aws-sdk-js-2.1545.0",
"clientId": "CLIENT_ID_NOT_APPLICABLE"
},
"triggerSource": "PreSignUp_AdminCreateUser",
"request": {
"userAttributes": {
"email": "[email protected]"
},
"validationData": null
},
"response": {
"autoConfirmUser": false,
"autoVerifyEmail": false,
"autoVerifyPhone": false
}
}
© 2022 - 2025 — McMap. All rights reserved.