Deploy on AWS
ECS Fargate runs your container, RDS runs Postgres and ElastiCache runs Redis. Start with the
server.ts and Dockerfile from the overview.
1. Postgres on RDS
Create an RDS for PostgreSQL 16 instance in your VPC and set Initial database name
to notifkit. RDS requires SSL, so add sslmode=require:
DATABASE_URL=postgres://USER:[email protected]:5432/notifkit?sslmode=require
URL-encode the password if it has special characters.
2. Redis on ElastiCache
- Create a Redis OSS cluster with cluster mode disabled. notifkit doesn't support Redis Cluster.
- Use a custom parameter group with
maxmemory-policyset tonoeviction. The ElastiCache default,volatile-lru, drops queued messages when memory runs low. - For production, add a replica with Multi-AZ so a node failure doesn't lose the queue.
# rediss:// (two s) when in-transit encryption is on, redis:// when it's off
REDIS_URL=rediss://your-redis.xxxx.cache.amazonaws.com:6379
3. Push the image to ECR
aws ecr create-repository --repository-name notifkit
aws ecr get-login-password | docker login --username AWS --password-stdin ACCOUNT.dkr.ecr.REGION.amazonaws.com
# Fargate runs x86 by default, so build for it even on an ARM Mac.
docker build --platform linux/amd64 -t ACCOUNT.dkr.ecr.REGION.amazonaws.com/notifkit:latest .
docker push ACCOUNT.dkr.ecr.REGION.amazonaws.com/notifkit:latest
4. Run it on ECS Fargate
Store the secrets in SSM Parameter Store, then create a task definition with this container:
{
"name": "notifkit",
"image": "ACCOUNT.dkr.ecr.REGION.amazonaws.com/notifkit:latest",
"portMappings": [{ "containerPort": 3000 }],
"stopTimeout": 45,
"environment": [
{ "name": "NODE_ENV", "value": "production" },
{ "name": "HOST", "value": "0.0.0.0" },
{ "name": "PUBLIC_URL", "value": "https://notify.example.com" }
],
"secrets": [
{ "name": "DATABASE_URL", "valueFrom": "arn:aws:ssm:REGION:ACCOUNT:parameter/notifkit/DATABASE_URL" },
{ "name": "REDIS_URL", "valueFrom": "arn:aws:ssm:REGION:ACCOUNT:parameter/notifkit/REDIS_URL" },
{ "name": "UNSUBSCRIBE_SECRET", "valueFrom": "arn:aws:ssm:REGION:ACCOUNT:parameter/notifkit/UNSUBSCRIBE_SECRET" },
{ "name": "ADMIN_API_KEY", "valueFrom": "arn:aws:ssm:REGION:ACCOUNT:parameter/notifkit/ADMIN_API_KEY" },
{ "name": "RESEND_KEY", "valueFrom": "arn:aws:ssm:REGION:ACCOUNT:parameter/notifkit/RESEND_KEY" }
]
}
Then create a service from it behind an Application Load Balancer:
- Target group: target type
ip, port3000, health check path/ready. - Listener: HTTPS on 443 with an ACM certificate. Point the
PUBLIC_URLdomain at the load balancer. - Security groups: the load balancer reaches tasks on 3000, and tasks reach RDS on 5432 and ElastiCache on 6379.
- The task execution role needs
ssm:GetParametersonparameter/notifkit/*.
stopTimeout: 45 gives in-flight sends time to finish before ECS kills the task.
The default, 30 seconds, can cut them off.
5. Create a project
curl -s -X POST https://notify.example.com/v1/projects \
-H "Authorization: Bearer $ADMIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"production"}'
More than one task
One task migrates the database on start. With more, set autoMigrate: false and run
migrations as a one-off task before each deploy:
aws ecs run-task --cluster notifkit --launch-type FARGATE --task-definition notifkit \
--network-configuration "awsvpcConfiguration={subnets=[subnet-xxx],securityGroups=[sg-xxx]}" \
--overrides '{"containerOverrides":[{"name":"notifkit","command":["npx","notifkit-migrate"]}]}'
Need help?
Stuck, or want us to deploy it for you? Email [email protected].