← Back to the blog

AWS & n8n • 2026-08-20 • 3 min read

Self-hosting n8n on AWS ECS with No Exposed Ports and Credentials in KMS

n8n is excellent at automation and alarming on a public IP. How we separate the editor, the workers and the webhook endpoint so none of them is reachable from the internet.

Self-hosting n8n on AWS ECS with No Exposed Ports and Credentials in KMS — AWS & n8n

n8n holds credentials for every system it touches. That makes the instance itself one of the most sensitive services you run, and putting its editor on a public address is a decision worth reconsidering.

Three roles, three deployments

The default container runs everything. We split it, because the three jobs have different exposure.

  • The editor — the UI and the API. No public ingress at all; reachable through a VPN or an identity-aware proxy
  • The workers — execute workflows, hold the credentials, live in a private subnet with no inbound rules
  • The webhook endpoint — the only component anything outside can reach, and it executes nothing

With queue mode and Redis between them, a webhook enqueues work and returns. The component exposed to the internet never runs a workflow.

What sits in front of the webhook

// text
Internet -> CloudFront + WAF -> ALB -> webhook task -> Redis -> workers (private)

Before a request reaches n8n it has passed four checks: WAF rate limiting by source, a path allow-list covering only /webhook/*, a body size limit, and HMAC verification of the signature the sender attached. The last one is the important one — an unauthenticated webhook path is an unauthenticated path into your automation, regardless of how unguessable the URL is.

We verify the HMAC in a small Rust service in front rather than in a workflow node, so an invalid request is rejected before it costs an execution.

Credentials

N8N_ENCRYPTION_KEY decrypts every stored credential. It lives in Secrets Manager, encrypted with a customer-managed KMS key, and is injected by the task definition — never in an image layer, never in an environment file in the repository.

Grant the task role kms:Decrypt on that one key, with a condition on the encryption context. The pattern is covered in the envelope encryption article; the short version is that a role allowed to decrypt everything is a role worth stealing.

Rotation is a genuine migration: re-encrypt the credential table with the new key before retiring the old one. Test it somewhere that is not production, because getting it wrong means every credential becomes unreadable at once.

Database and backups

Postgres on RDS rather than the bundled SQLite. Executions are written on every run, so an active instance generates real volume — set EXECUTIONS_DATA_PRUNE and a retention window, or the table becomes the largest thing you own.

Back up the database *and* the encryption key, and confirm that a restore in a fresh account produces working credentials. A backup you have not restored is a belief, not a backup.

What we monitor

  • Failed executions by workflow, which is the first sign a credential expired
  • Queue depth, which separates "n8n is slow" from "the thing n8n is calling is slow"
  • Webhook rejections at the edge, by reason
  • Any change to the workflow set, shipped to the audit log — a workflow is code, and it changed without a pull request

Read next

COOKIES // MEASUREMENT

We count page views through Google Tag Manager. Say yes and it may store a cookie in your browser; say no and it still counts the visit, without storing anything and without an identifier. Nothing here is used for advertising.

Cookie Policy — you can change this at any time from the footer of any page.