AWS Logo
Menu
Deploy N8N in AWS using ECS and CDK

Deploy N8N in AWS using ECS and CDK

N8N hosted on AWS ECS cluster

Published May 9, 2025

Introduction

In the AWS ecosystem, we already have grate tools like Step Functions, Bedrock Flow for native service integrations. If you’d like to check out n8n and try deploying it on AWS using Amazon Elastic Container Service
Recently, I started experimenting with n8n by running it locally using Docker Compose, which launched the core service along with Postgres and Redis. Not long after, I decided to move it to AWS. While n8n supports deployment on Amazon EC2 instance and EKS, I built a proof of concept using CDK to deploy it on Amazon Elastic Container Service.
It’s still a work in progress, but I wanted to share this experience with the community.

Deployment process

The deployment process is simple just clone the repository from my GitHub and launch the stacks.
The architecture is built using modular AWS CDK stacks deployed within a custom VPC. Each component is decoupled using AWS Systems Manager Parameter Store, allowing for flexible configuration and easier maintenance. Sensitive information is securely managed through AWS Secrets Manager.
The deployment provisions PostgreSQL, Redis, EFS, and all core N8N services and workers, running as ECS services. For production environments, it's recommended to move the database layer outside of containers. An optional RDS stack for PostgreSQL is included (but not deployed by default), and using Amazon ElastiCache for Redis offers improved performance and resilience.
A step-by-step deployment guide is available in the README.md file within the repository.
CDK Stacks
  • N8nDevNetworkStack
  • N8nDevEfsStack
  • N8nDevRdsStack (optional)
  • N8nDevEcsClusterStack
  • N8nDevBastionHostStack
  • N8nDevServiceDatabaseStack
  • N8nDevServiceRedisStack
  • N8nDevN8NServiceStack
Once the solution is deployed, you'll find several ECS services up and running within your cluster. These include the core N8N service, background workers, and supporting services like Postgres and Redis. Each component is containerized and orchestrated via ECS, ensuring scalability and ease of management.
The architecture also integrates AWS Cloud Map for service discovery, allowing the different containers and services to communicate seamlessly within the VPC without hardcoding IP addresses or hostnames. This simplifies inter-service communication and improves flexibility in scaling or updating components.
Additionally, the setup includes persistent storage with EFS and an optional RDS stack for those who prefer a managed database outside the containerized environment. It’s a solid foundation for running N8N in a robust, cloud-native manner on AWS.
ECS
N8N Services
The N8N editor is exposed via an Application Load Balancer (ALB) and is currently accessible over HTTP. To enable secure access, SSL termination and an HTTPS listener should be configured. The necessary code is already included but commented out in the CDK stack. To enable HTTPS, simply uncomment the relevant sections, create or import an SSL certificate, and redeploy the service.
N8N-Editor
Editor

 Conclusion
The N8N workflow tool can be deployed on ECS I’ve set up a proof of concept (POC) to demonstrate this. While it works, additional steps are needed to make it production-ready, such as implementing SSL, testing the workers, and securing the ALB endpoint with a WAF.
If you're considering a self-hosted N8N instance, ECS is definitely worth exploring. Let me know what you think!
 

2 Comments