This project deploys n8n (workflow automation tool) on AWS ECS Fargate with HTTPS support.
- AWS CLI configured with appropriate credentials
- Node.js and npm installed
- AWS CDK installed (
npm install -g aws-cdk)
- Clone the repository
- Install dependencies:
npm install
- Copy
.env.local.templateto.env.localand fill in your values:cp .env.local.template .env.local
- Edit
.env.localwith your configuration:DOMAIN_NAME: Your domain name (e.g., example.com)N8N_BASIC_AUTH_USER: Username for n8n basic authN8N_BASIC_AUTH_PASSWORD: Password for n8n basic authN8N_ENCRYPTION_KEY: Encryption key for n8n
-
Bootstrap your AWS environment (if not already done):
cdk bootstrap aws://YOUR_ACCOUNT_ID/YOUR_REGION
-
Deploy the stack:
cdk deploy
-
After deployment, you'll receive:
- Load Balancer DNS name
- Service URL
-
Configure DNS:
- Create a CNAME record in your DNS provider pointing your domain to the Load Balancer DNS name
- Wait for ACM certificate validation (can take up to 30 minutes)
The stack creates:
- VPC with public and private subnets
- ECS Fargate cluster
- RDS PostgreSQL database
- Application Load Balancer with HTTPS support
- ACM Certificate for your domain
- n8n service with basic authentication
- Database is in private subnets
- HTTPS enforced with automatic HTTP to HTTPS redirect
- Basic authentication enabled
- Secure cookies enabled
- Database credentials stored in AWS Secrets Manager
To remove all resources:
cdk destroy