Metadata-Version: 2.5
Name: n8n-on-aws
Version: 261130
Summary: One YAML file, every shade of n8n on AWS: configuration-driven CDK deployment of n8n on ECS or EKS.
Project-URL: Homepage, https://github.com/bernard357/n8n-on-aws
Project-URL: Issues, https://github.com/bernard357/n8n-on-aws/issues
Author: Bernard Paques
License: MIT
License-File: LICENSE
Keywords: aws,cdk,cloudformation,ecs,eks,fargate,finops,n8n
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Systems Administration
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: aws-cdk-lambda-layer-kubectl-v35<3,>=2.2
Requires-Dist: aws-cdk-lib<3,>=2.277
Requires-Dist: constructs<11,>=10
Requires-Dist: pydantic<3,>=2.7
Requires-Dist: pyyaml>=6
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Description-Content-Type: text/markdown

# n8n-on-aws

**One YAML file, every shade of n8n on AWS.** A configuration-driven CLI that turns a typed,
validated YAML file into AWS CDK (Python) stacks. It covers everything from a single Fargate task to
multi-main HA on ECS or EKS, creates what is missing, and reuses what you already have.

```bash
n8n-on-aws init                                                   # assistant writes n8n.yaml
n8n-on-aws deploy -f fixtures/configuration/minimal.yaml --dry-run
n8n-on-aws deploy -f fixtures/configuration/minimal.yaml
```

> Status: pre-alpha. The configuration model, the rule engine (topology, n8n licensing,
> FinOps) and CDK synthesis on **ECS Fargate**, ECS on EC2 and **EKS** work. About ten shapes
> were smoke-tested on a real account (eu-west-3): `minimal`, the ALB and queue shapes with
> Spot workers, the split topology behind a Cognito login wall, Cognito and WAF at the edge,
> EKS Auto Mode with the official Helm chart, and cross-region backup copies. Multi-main is
> synthesized and tested, not deployed, because it needs an n8n Enterprise licence. See the
> [roadmap](#roadmap) and the [shapes](https://bernard357.github.io/n8n-on-aws/shapes).

**Cost.** `nano` is about $4 and `minimal` about $72 a month. Always run `destroy` and
`cleanup` after a test. `plan --cost` prints the estimate before you deploy.

**Documentation:** <https://bernard357.github.io/n8n-on-aws/>

## Quick start (from source)

```bash
git clone https://github.com/bernard357/n8n-on-aws.git && cd n8n-on-aws
make setup
.venv/bin/n8n-on-aws init                       # questions, then a commented n8n.yaml
.venv/bin/n8n-on-aws plan -f n8n.yaml --cost
.venv/bin/n8n-on-aws validate -f fixtures/configuration/nano.yaml
.venv/bin/n8n-on-aws plan -f fixtures/configuration/queue-workers.yaml --show-env
.venv/bin/n8n-on-aws plan -f fixtures/configuration/queue-workers.yaml --cost
.venv/bin/n8n-on-aws deploy -f fixtures/configuration/enterprise-ha.yaml --dry-run
.venv/bin/n8n-on-aws validate -f fixtures/configuration/minimal.yaml --set topology.mode=multi-main
```

The last command fails on purpose: multi-main needs the n8n Enterprise edition. Every
finding has a stable code: `S` schema, `T` topology, `L` licence, `F` FinOps, `C`
synthesis. Point your editor at [schema/n8n-on-aws.v1.json](schema/n8n-on-aws.v1.json)
for completion.

## Deploying

You need Node.js (for `npx aws-cdk@2`), AWS credentials, and a bootstrapped account and
region (`npx aws-cdk@2 bootstrap`, plus `us-east-1` when CloudFront needs a certificate).

```bash
.venv/bin/n8n-on-aws diff -f my-n8n.yaml
.venv/bin/n8n-on-aws deploy -f my-n8n.yaml
.venv/bin/n8n-on-aws destroy -f my-n8n.yaml
.venv/bin/n8n-on-aws cleanup -f my-n8n.yaml   # hours later, with cloudfront-cognito
.venv/bin/n8n-on-aws cleanup -f my-n8n.yaml --purge   # also the retained secret and snapshots
```

`destroy` stops with a hint when the managed database has deletion protection and the
environment is not `dev`: set `environment: dev` or `database.deletion_protection: false`,
deploy again, then destroy. `cleanup` deletes the log groups of the stacks and of CDK helper
functions (deployment region, us-east-1 and the backup copy region, plus
`/aws/containerinsights/<name>/` on EKS), the DNS validation record of a certificate the tool
created, and the Lambda@Edge function. It asks first, and without a terminal it needs `--yes`.
`--purge` lists then deletes the encryption key secret and the database snapshots, which
makes backups unreadable.

CDK assets live in the bootstrap stack (`CDKToolkit`). It is not removed by `destroy`.

The deployment is split into stacks: `<name>-network`, `<name>-data`, `<name>-n8n`, and
`<name>-edge` in us-east-1 when needed. The encryption key secret, database snapshots,
the bucket and EFS are retained when stacks are deleted, except with `environment: dev`.
After the first deployment, open the URL printed as the `Url` output and create the n8n
owner account.

## Operating

Each deployment gets one CloudWatch dashboard, named after the deployment and printed as
the `DashboardUrl` output. It is generated from the resources that were synthesized, so it
follows the configuration:

- a header with the edition, version and links to n8n, its logs and its ECS cluster
- alarm status, and task counts per role when Container Insights is on
- CloudFront (metrics from us-east-1) or the load balancer
- CPU and memory of each n8n role, and of the runner sidecars with Container Insights
- Logs Insights tables of recent errors per role
- the database, queue, EFS, bucket, NAT and origin-updater Lambda, when they exist
- links to Cost Explorer, the budget and cost anomalies

Resources outside AWS (an external database or Redis, the NAT of an existing VPC) appear
as a note, never silently left out. A test checks that every resource of a monitored type
in the templates has a widget.

Alarms are always created, because the dashboard shows them. They send email only when
`observability.alarms.email` is set. Turn the dashboard off with
`observability.dashboard.enabled: false` (the default for `nano`).
With several deployments in one account and region, one overview dashboard answers "which
one needs me?":

```shell
.venv/bin/n8n-on-aws overview [--region eu-west-3]            # list what it finds, write nothing
.venv/bin/n8n-on-aws overview [--region eu-west-3] --deploy   # write the dashboard n8n-on-aws-overview
.venv/bin/n8n-on-aws overview [--region eu-west-3] --delete   # remove it
```

It has one row per deployment: alarm status, service CPU and running tasks, CloudFront or load
balancer requests and 5xx, database capacity, and links to the editor, the deployment's own
dashboard and Cost Explorer filtered on its tag. The deployments are found by the
`n8n-on-aws:deployment` tag of their stacks, not by name. The dashboard is written with
`put-dashboard` and belongs to no stack, so `destroy` leaves it alone. Run `--deploy` again
after adding or removing a deployment. It is one more dashboard: $3 a month beyond the
first 3 in the account.

## Why this exists

Each existing n8n-on-AWS project picks one shade: one Fargate task, one Terraform module, one
Helm chart. This tool describes the deployment in one validated file instead, shows its cost
before anything is created, and rejects combinations that n8n or its licence do not allow.
The design notes (deployment options, configuration reference, CLI, licensing, FinOps,
Application Signals) are on the [documentation site](https://bernard357.github.io/n8n-on-aws/)
and in [documentation/](documentation).

## Choosing a runtime

The n8n roles (main, webhook processors, workers) are the same everywhere; `runtime` only picks
the AWS building blocks that run them.

| You are… | Use | Status |
|---|---|---|
| New to n8n on AWS, small or medium workload, cost-sensitive | `runtime.platform: ecs` on Fargate, `ingress.kind: cloudfront` | ✅ |
| Handling many webhooks or a steady execution load | ECS on Fargate, `topology.mode: queue` or `split`, workers on Spot | ✅ |
| Holding Savings Plans or Reserved Instances, steady load, or needing more memory per vCPU | ECS on EC2 hosts (`runtime.ecs.capacity: ec2`), Graviton by default, workers on Spot hosts | ✅ |
| Already running Kubernetes (Helm, GitOps, policies) | `runtime.platform: eks`, the official n8n Helm chart on a new or an existing cluster | ✅ [#11](https://github.com/bernard357/n8n-on-aws/issues/11) |

## Sample configurations

From smallest to largest, in [fixtures/configuration](fixtures/configuration):

| File | Shade |
|---|---|
| `minimal.yaml` | Name + community usage declaration. Small profile: one Fargate task behind CloudFront, Aurora Serverless, new VPC |
| `nano.yaml` | Fargate Spot + SQLite on EFS behind CloudFront (no ALB, no NAT), Cognito at the edge, budget, office hours |
| `small-team.yaml` | Registered community, Aurora Serverless, CloudFront + Cognito with MFA, backups, alarms, budget |
| `queue-workers.yaml` | Business, queue mode, Spot workers scaled on queue depth, ElastiCache Serverless, S3 binary data, Entra ID via ALB OIDC |
| `split-webhooks.yaml` | Main + webhook + workers, CloudFront + WAF in front of the ALB, Cognito at the edge |
| `enterprise-ha.yaml` | Multi-main Enterprise, provisioned Aurora, KMS, S3 execution data, n8n OIDC SSO |
| `ec2-capacity.yaml` | Queue mode on ECS with EC2 hosts: Graviton on-demand group for main, Spot group from zero for workers |
| `existing-landing-zone.yaml` | Brownfield ECS: existing VPC, cluster, Aurora, bucket, Cognito and certificate |
| `eks-new-cluster.yaml` | New EKS Auto Mode cluster with the official n8n Helm chart |
| `eks-existing-cluster.yaml` | Existing EKS cluster, external PostgreSQL and Redis |

The n8n version `2.37.1` in the samples is a placeholder for "a pinned release".

## Roadmap

| Area | Status |
|---|---|
| Configuration model, profiles, licence and FinOps rules | ✅ [#1](https://github.com/bernard357/n8n-on-aws/issues/1) |
| ECS Fargate: network, data, services, ALB, CloudFront (ALB or task origin), Cognito and OIDC on the ALB, budgets, schedules | ✅ [#2](https://github.com/bernard357/n8n-on-aws/issues/2) |
| Smoke test of `minimal` (CloudFront to task, Aurora Serverless, runners) on a real account | ✅ |
| CloudWatch dashboard and alarms generated from the deployed resources | ✅ [#3](https://github.com/bernard357/n8n-on-aws/issues/3) |
| Smoke test of the ALB and queue shapes (Spot workers, ElastiCache Serverless, NAT) and of both dashboards | ✅ [#3](https://github.com/bernard357/n8n-on-aws/issues/3) |
| Smoke test of the split topology (webhook processors) behind an HTTPS ALB with a Cognito login wall | ✅ |
| Smoke test of multi-main (needs an n8n Enterprise licence) | not planned |
| Verify Aurora scale-to-zero, binary-data defaults and public paths (measured on a real account) | ✅ [#4](https://github.com/bernard357/n8n-on-aws/issues/4) |
| Worker scaling on queue depth (0 → 3 → 0 on a real account), n8n Prometheus metrics in CloudWatch | ✅ [#5](https://github.com/bernard357/n8n-on-aws/issues/5) |
| Cognito at the edge (`cloudfront-cognito`, Lambda@Edge): redirect and open paths smoke-tested | ✅ [#6](https://github.com/bernard357/n8n-on-aws/issues/6) |
| WAF and IP allow-list on CloudFront, smoke-tested on a real sub-domain | ✅ [#7](https://github.com/bernard357/n8n-on-aws/issues/7) |
| Cost estimate in `plan`, `max_monthly_usd` guard | ✅ [#8](https://github.com/bernard357/n8n-on-aws/issues/8) |
| `n8n-on-aws init` assistant | ✅ [#9](https://github.com/bernard357/n8n-on-aws/issues/9) |
| ECS on EC2 capacity (Auto Scaling groups, Spot hosts for workers) | ✅ [#10](https://github.com/bernard357/n8n-on-aws/issues/10) |
| EKS with the official Helm chart (Auto Mode or managed nodes, KEDA, External Secrets, Pod Identity, ALB with Cognito or OIDC) | ✅ smoke-tested on a new Auto Mode cluster; CloudFront in front of EKS smoke-tested with the edge wall [#11](https://github.com/bernard357/n8n-on-aws/issues/11) |
| Cross-region backup copies, smoke-tested through the nightly rule and a restore | ✅ [#12](https://github.com/bernard357/n8n-on-aws/issues/12) |
| Overview dashboard across deployments (`overview` verb) | implemented, smoke test pending [#13](https://github.com/bernard357/n8n-on-aws/issues/13) |
| CloudWatch Application Signals (spike): measured, not worth a default, see the [design note](documentation/application-signals-workbook.md) | ✅ [#14](https://github.com/bernard357/n8n-on-aws/issues/14) |

On EKS the load balancer is created by the AWS Load Balancer Controller after the Helm release; the stack waits for it by name, then points `ingress.domain` at it, or at CloudFront when it is in front.
