Adding Custom Cognito SignUp Message with Terraform, Lambda, and Compoze

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 .

Custom Message Trigger


In order to create this custom signup flow we needed to do the following:

  1. Create a custom Lambda Function to handle the Custom Message Trigger
  2. Update the Lambda Function to create our custom message with the generated confirmation link
  3. Update our Cognito instance to include the trigger (in our case we used Terraform to handle our Cognito configuration)


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.

sam_custom_message_handler – Medium

Once we have that, we need to create our Lambda Handler to generate our custom signup link and update the email message.

custom_message_handler – Medium

Then, we push and deploy!

Once our Lambda functions are deployed, we can update our Terraform module to contain the Lambda ARNs

cognito_terraform_custom_message – Medium

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 at


Speak to a Compoze Labs expert


(952) 232-5103 

Compoze Labs Offices

1313 Chestnut Ave., Suite 200, Minneapolis, MN 55403

323 E Wacker Dr.

STE 808

Chicago, IL 60601

Copyright© Compoze Labs LLC 2021 All Rights Reserved

A note to our visitors

By continuing to use this site, you are agreeing to our

Privacy Policy