| Key | Value |
|---|---|
| Services | Cognito |
| Integrations | AWS CLI |
| Categories | Authentication; Serverless |
A demo application illustrating Cognito authentication and user pools running locally using LocalStack. The sample creates a Cognito user pool, registers a user, handles email verification, and demonstrates JWT-based authentication — all without connecting to AWS.
To receive Cognito email verification codes locally, configure the following environment variables before starting LocalStack:
SMTP_HOST: hostname and port of your SMTP server (e.g.,host.docker.internal:2525)SMTP_USER: SMTP username (optional)SMTP_PASS: SMTP password (optional)SMTP_EMAIL: email address used to send messages
- A valid LocalStack for AWS license. Your license provides a
LOCALSTACK_AUTH_TOKENto activate LocalStack. - Docker
localstackCLIawslocalCLI
make checkmake installexport LOCALSTACK_AUTH_TOKEN=<your-auth-token>
make startmake runThe script runs an interactive Cognito authentication scenario. Make sure to configure the environment variable $USER_EMAIL with an email address before running.
At certain points, the script will prompt you to enter a confirmation code that has been sent to your email address (the code is also printed in the LocalStack logs):
Please check email inbox for ..., and enter the confirmation code below:
The script will then also ask you to specify a password reset code that is sent to your email:
Please check email inbox for ..., and enter the password reset code here:
Credits: Kudos to
@Jaystified, Kurusugawa Computer Inc. who kindly provided the initial version of the testing script intest.sh.
This code is available under the Apache 2.0 license.