Run n8n on AWS for less than a cup of coffee per month

n8n is a workflow automation tool that you can use for workflow automation, it is a similar tool to Zapier and is more developer oriented. I recently found that a customer required to launch n8n in multiple environments within AWS, so I decided to build a Terraform module that handles this for you.

Run n8n yourself

To run n8n yourself you have a couple of options:

  • You use the Cloud Edition which is 20 EUR per month, in this case n8n will be run on AWS by N8n themselves
  • You follow n8n instructions to set up a Kubernetes cluster, in this case n8n will run within your own AWS environment

I did not like these options for a couple of reasons:

  1. Using the Standard Cloud Edition imposes limits on the number of workflows and workflow executions (it also gives a single user)
  2. The Kubernetes approach is costly because a Kubernetes cluster is 72 USD per month (without the pods)
  3. Setting up Kubernetes and managing it (even through EKS) can be pretty daunting

My customer also required this n8n cluster in all their AWS environments. This would lead to excess costs as the EKS cluster would need to be setup in every organization. For a production setup I would certainly advise you to use the Cloud Edition. But if you just want to run it cheaply you can use this Terraform module.

n8n vs AWS costs for this module

The costs of this running this module are:

  • The costs for running the container on ECS – 2.66 USD per month (Ireland region, Fargate Spot pricing)
  • The application load balancer – 18USD per month (note that this load balancer is eligible for the free tier, so I don’t include it in the costs. Also, if you are in the US Coffee is probably 20 dollars so it is about right!)
  • EFS storage: Practically free because only the n8n configuration is stored here

Also with the load balancer, you might be able to run a single load balancer for multiple target groups. This means you can share the load balancer costs across multiple applications. ALB’s scale well so you can combine them just fine for light load applications. The load balancer does not have SSL enabled, you can use a free service like Cloudflare for that.

n8n Terraform module instructions

To run this module in a pre-production environment use this code:

module "n8n" {
  source  = "elasticscale/n8n/aws"
  version = "2.0.2"
}

If you want to use this module in production you can use it as follows:

module "n8n" {
  source          = "elasticscale/n8n/aws"
  version         = "2.0.2"
  certificate_arn = "arn:aws:acm:region:account:certificate/certificate_ID"
  fargate_type    = "FARGATE"
  desired_count   = 2
}

Make sure to backup the EFS volume with a tool like AWS backup. n8n can give issues if you set the desired count larger than 1. I specifically had problems with the webhooks registering on other instances when I had more than one container running. Maybe sticky sessions could help in this case.

Other Terraform modules

Also check out some other Terraform modules we have built at ElasticScale: