Notification
Build and deploy your email and sms notification service with CDK.
Prerequisites
- Node.js 22+
- AWS account
- The same deployment IAM user described in the Infrastructure quick start
- A Resend API key (email)
- A Twilio account (SMS, optional)
AWS charges apply. Deploying the notification service updates the AWS Core Stack and may provision or update billable resources in your account. If you're only evaluating the project, destroy the stacks when you're finished to avoid ongoing costs.
The notification service runs as an AWS Lambda application. It is triggered by EventBridge and is not designed to run as a standalone HTTP server.
Steps
1. Confirm AWS access
Use the same AWS account and deployment IAM user you created for the Infrastructure quick start. If you use a named AWS CLI profile for infrastructure deploys, use the same profile here as well.
2. Configure notification environment variables
Add the notification settings to infrastructure/aws/.env.
These values live alongside the rest of your infrastructure configuration, so if you have already completed the infrastructure quick start you can usually just update the existing .env file.
AWS_ACCOUNT_ID=123123123123
AWS_REGION=eu-west-1
WEBSITE_URL=https://rawstack.io
# Email
RESEND_API_KEY=your_resend_api_key_here
EMAIL_FROM_ADDRESS=yo@test.com
OVERRIDE_RECIPIENT_EMAIL=hi@test.com
# Twilio SMS configuration (optional - SMS is only enabled when all three are set)
# TWILIO_ACCOUNT_SID=your_twilio_account_sid_here
# TWILIO_AUTH_TOKEN=your_twilio_auth_token_here
# TWILIO_FROM_NUMBER=+1234567890Use OVERRIDE_RECIPIENT_EMAIL in development or staging if you want all outbound emails redirected to your own address.
Set WEBSITE_URL to the app URL for the environment you are deploying.
If you only want email notifications, leave the Twilio values unset.
3. Deploy the notification service
Deploy the CDK Core Stack, which includes the notification Lambda:
cd infrastructure/aws
npm run cdk deploy coreWith a named profile:
cd infrastructure/aws
AWS_PROFILE=<PROFILE_NAME> npm run cdk deploy coreAfter deployment, EventBridge rules in the Core Stack route supported events to the notification Lambda automatically.
For local iteration, template previews, and direct handler testing, see Notification development and Notification testing.
Email templates
Emails are built with React Email. The templates live in services/notification/src/content/email/template/ and are standard React components.
To create or modify templates, scaffold a React Email project in a separate directory using:
npx create-email@latestBuild or edit your templates there using the built-in preview server, then copy the finished .tsx files into services/notification/src/content/email/template/.
Find out more about the notification service by reading the in-depth deep dive.