AWS Cognito is a secure and scalable user access management solution offered by Amazon Web Services. At Compoze Labs it is our go to solution for managing users when building apps in AWS.
Compoze is a platform that enables the rapid, secure, and scalable development of software products in AWS.
Cognito provides an easy way to send emails to your users during various user events such as: verifications, invitations, and MFA events.
However, if you want to add customization to these messages you need to create Lambda Triggers that fire during each of these events. These triggers can be executed during: pre-signup, pre-authentication, post-authentication, etc. The full list can be found in the AWS Docs.
For a recent app, we needed to implement a confirmation email when a user signed up. We wanted to have a custom link that the user would click, that would then redirect back to our app to confirm their user. In order to do this we needed to create a Lambda handler for the Custom Message Signup trigger .
In order to create this custom signup flow we needed to do the following:
The first thing we needed to do was create the Lambda project. With the Compoze CLI we quickly spun up our base Lambda project
Now we have a basic Lambda project configured with source code and a working deployment pipeline.
Next, we need to create our Lambda Handler to be able to process the custom message triggers.
First we need to update our AWS SAM template with our function definition.
Once we have that, we need to create our Lambda Handler to generate our custom signup link and update the email message.
Then, we push and deploy!
Once our Lambda functions are deployed, we can update our Terraform module to contain the Lambda ARNs
After a simple terraform plan and terraform deploy we’re all set!
If you’re interested in learning more about how your team can leverage the Compoze CLI and the Compoze Platform reach out to us.