1 Answer
- Newest
- Most votes
- Most comments
0
Hey, @josphr. Excellent question.
If you are wanting to trigger some code when a user verifies their email address, there's a few different ways you could go to achieve this.
Cognito Events (quickest, but perhaps not feasible)
- This is triggered after a user confirms their account. I'm not familiar with your architecture, but you may be able to use this event to update the user's email in the database. Though this may be the quickest approach, I'm not confident the identity provider changing will trigger this. You'll know that better than me.
- This is triggered after a user is authenticated, but before the tokens are given. A bit gross, but you could do a manual check here with the user's email address in the database and with what exists in the token. If they are different, update the database. I would prefer the post-confirmation trigger or EventBridge over this, though - just giving you another option to think about.
EventBridge Rule (most involved, but the most feasible)
- If listening to the post-confirmation isn't a solution for you, this is my recommended solution. My team has many production workloads listening to EventBridge events and responding with Lambda Function invocations. And, you can filter EventBridge events to only those you care about. Otherwise, it would be pretty expensive to trigger a Lambda Function each time, and discard the events you don't care about. Let's let AWS do the work + filtering for us ;)
- Information on filtering down those events can be found here.
- Also, be warned: idempotency is a bigger need when using EventBridge to trigger Lambda Functions than one may think. Your Lambda may be invoked more than once when being paired with EventBridge. Thankfully, AWS provides idempotency tools to help with this. If you don't care if your Lambda could be invoked more than once, that's okay, but if you do, more info on that here. They offer support for idempotency in different runtimes.
answered 8 months ago
Relevant content
- asked 4 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago