At a glance
| What | Value |
|---|---|
| Good for | Teams that already run on AWS and want managed containers and a managed database |
| Time to deploy | About 20 minutes, most of it waiting for RDS |
| Cost | From $112.74/month in us-east-1 (see below) |
The Terraform passes validation and parts of it were run locally, but a full apply against a real AWS account has not been run yet. The Tested section below lists what was and was not checked.
What this sets up
- A VPC across two availability zones: public subnets for the load balancer, private subnets for Palace and the database, one NAT gateway for outbound traffic (image pulls, license check, Secrets Manager).
- RDS for PostgreSQL 17 (single-AZ by default), encrypted, not publicly reachable, 7 days of automated backups and point-in-time recovery, deletion protection, a final snapshot on destroy. RDS keeps the master password in Secrets Manager. Only the Palace tasks and the setup task can connect. Palace connects as
palace_appover TLS (sslmode=verify-fullwith the RDS certificate bundle), and that role cannot bypass row-level security. - ECS Fargate: two Palace Server tasks (0.5 vCPU, 1 GB, Graviton) in the private subnets with no public IP, as UID 10001 with a read-only filesystem and all Linux capabilities dropped. A small init container downloads the RDS certificate bundle before Palace starts. Failed deployments roll back.
- Secrets Manager for the license key, JWT secret, bootstrap token,
palace_apppassword and the full database URL. ECS injects them at start; each task's role can read only its own secrets. - An Application Load Balancer with an ACM certificate (DNS-validated), TLS 1.2 and 1.3 only, HTTP to HTTPS redirect and HSTS.
/metricsalways returns 404./bootstrapreturns 404 unless the request carries the bootstrap token and bootstrap is enabled. - A Route 53 alias record for your domain and CloudWatch Logs with 30 days of retention.
Costs
Prices checked 2026-11-29, USD per month (730 hours) before tax, read from the AWS Price List API (publications of 25 to 27 November 2026, effective 1 November 2026) that feeds these pages: Fargate ↗, RDS for PostgreSQL ↗, Elastic Load Balancing ↗, VPC (NAT gateway, public IPv4) ↗, Secrets Manager ↗, Route 53 ↗, CloudWatch ↗. The ACM certificate is free.
Small (default): 2 tasks of 0.5 vCPU / 1 GB on ARM, db.t4g.micro, 20 GB. Medium: 2 tasks of 1 vCPU / 2 GB on ARM, db.t4g.small, 50 GB.
| Line | Small us-east-1 | Small eu-central-1 | Medium us-east-1 | Medium eu-central-1 |
|---|---|---|---|---|
| Fargate (ARM) | $28.84 | $33.16 | $57.67 | $66.33 |
| RDS PostgreSQL, single-AZ | $11.68 | $13.87 | $23.36 | $27.01 |
| RDS gp3 storage | $2.30 | $2.74 | $5.75 | $6.85 |
| NAT gateway, hourly | $32.85 | $37.96 | $32.85 | $37.96 |
| NAT data processed (10 GB / 50 GB assumed) | $0.45 | $0.52 | $2.25 | $2.60 |
| Load balancer, hourly | $16.43 | $19.71 | $16.43 | $19.71 |
| Load balancer LCUs (1 / 2 assumed) | $5.84 | $5.84 | $11.68 | $11.68 |
| Public IPv4 (NAT + 2 for the load balancer) | $10.95 | $10.95 | $10.95 | $10.95 |
| Secrets Manager (5 + the RDS master secret) | $2.40 | $2.40 | $2.40 | $2.40 |
| Route 53 hosted zone | $0.50 | $0.50 | $0.50 | $0.50 |
| CloudWatch Logs ingestion (1 GB / 5 GB assumed) | $0.50 | $0.63 | $2.50 | $3.15 |
| Total | $112.74 | $128.28 | $166.34 | $189.14 |
Rates used (us-east-1 / eu-central-1):
| Item | us-east-1 | eu-central-1 |
|---|---|---|
| Fargate ARM per vCPU-hour | $0.03238 | $0.03725 |
| Fargate ARM per GB-hour | $0.00356 | $0.00409 |
| Fargate x86 per vCPU-hour / GB-hour | $0.04048 / $0.004445 | $0.04656 / $0.00511 |
RDS PostgreSQL db.t4g.micro single-AZ per hour | $0.016 | $0.019 |
RDS PostgreSQL db.t4g.small single-AZ per hour | $0.032 | $0.037 |
| RDS gp3 storage per GB-month | $0.115 | $0.137 |
| ALB per hour / per LCU-hour | $0.0225 / $0.008 | $0.027 / $0.008 |
| NAT gateway per hour / per GB processed | $0.045 / $0.045 | $0.052 / $0.052 |
| Public IPv4 address per hour | $0.005 | $0.005 |
| Secrets Manager per secret-month | $0.40 | $0.40 |
| Route 53 hosted zone per month (first 25) | $0.50 | $0.50 |
| CloudWatch Logs ingestion per GB (Standard) | $0.50 | $0.63 |
The NAT gateway and the load balancer are about half the bill and do not grow with your team. LCUs, NAT data and log volume depend on use: the amounts above are assumptions, not measurements. Data transfer out to the internet, RDS backup storage beyond the free allowance, free tiers and Savings Plans are not included. Skip the hosted zone line if you already pay for it. db_multi_az = true adds a standby and about doubles the RDS lines. cpu_architecture = "X86_64" costs about 25% more for Fargate. Your Palace license is billed separately.
Steps
Prepare
- AWS credentials for the target account (
aws configure, SSO orAWS_PROFILE) and the AWS CLI. - A public Route 53 hosted zone that contains your domain, for example
yourco.comforpalace.yourco.com. - A license key from palacememory.com.
- Terraform 1.6+ or OpenTofu.
Configure
git clone https://github.com/AncientiCe/palace-server-examples.git
cd palace-server-examples/aws
cp terraform.tfvars.example terraform.tfvars # edit it
export TF_VAR_license_key='your-license-key'Terraform state holds the generated secrets (database password, JWT secret, bootstrap token). For anything beyond a trial, keep state in an encrypted remote backend such as a private S3 bucket with encryption on.
Deploy
terraform init
terraform applyThen prepare the database once. This runs a short Fargate task as the RDS master user: it creates the vector and pgcrypto extensions and the palace_app role (db-setup.sh ↗), and is safe to run again.
eval "$(terraform output -raw db_setup_command)"
aws logs tail "$(terraform output -raw log_group)" --log-stream-name-prefix db-setup --followWait for Database ready for Palace. and press Ctrl+C. Until the setup has run, Palace tasks cannot reach the database and ECS keeps replacing them; that is expected. A few minutes later https://<your domain>/readyz returns 200.
Create the first admin
Bootstrap runs from your machine through the load balancer, which forwards /bootstrap only with the right X-Bootstrap-Token header.
terraform output -raw bootstrap_command # edit the three values, then run itSave the api_key and org_id. Then turn bootstrap off, which removes the load balancer rule and the token from the tasks:
# in terraform.tfvars
enable_bootstrap = false
terraform applyWhile bootstrap is on, the token is also visible in the load balancer rule to anyone in your AWS account with permission to describe load balancers. Turn it off right after creating the admin; after that the token does nothing anyway, because bootstrap works only once.
Connect your team
Follow Connect clients with your URL.
Upgrade
Set the new tag and apply. ECS starts tasks on the new version, moves traffic to them and rolls back if they do not become healthy.
# in terraform.tfvars
palace_version = "<new version>"
terraform applyRestore
RDS restores a point in time to a new instance (guide ↗). Create it in the same subnet group and security group, put its endpoint in the database-url secret in Secrets Manager, then aws ecs update-service --cluster palace --service palace --force-new-deployment. Terraform still tracks the old instance; bring the code in line before your next apply.
Tested
The Terraform passes terraform fmt -check and terraform validate (Terraform 1.9.8, AWS provider 5.100.0). db-setup.sh was run twice against a local pgvector/pgvector:pg17 container, from the same postgres:17 client image the setup task uses, as a non-root user with a read-only filesystem and no capabilities: the second run changes nothing, palace_app has rolsuper = f and rolbypassrls = f, and both extensions exist. The init container pattern (download the RDS bundle as root with no capabilities into an empty root-owned volume, read it as UID 10001) was run locally with Docker.
A full apply against a real AWS account has not been run yet. Not tested: the ACM certificate, load balancer rules, Fargate volume permissions, the setup task on RDS (where the master user is rds_superuser, not a superuser) and the restore steps. If something fails, open an issue ↗.
Troubleshooting
- Palace tasks keep stopping: check that the setup task ran, then
aws logs tail /ecs/palace --log-stream-name-prefix palace. An expired or wrong license stops startup. - First deployment marked failed: if the circuit breaker gave up before you ran the database setup, start again with
aws ecs update-service --cluster palace --service palace --force-new-deployment. - Init container fails pulling
curlimages/curl: Docker Hub limits anonymous pulls per NAT address. Copy the image to your own ECR repository and setcurl_image. /bootstrapreturns 404: check the token header and thatenable_bootstrapis still true. After the first admin exists it returns 409.terraform destroyfails on the database: setdb_deletion_protection = false, apply, then destroy. Delete or rename an olderpalace-pg-finalsnapshot first.- Something else? Open an issue ↗
Nomad, Hetzner, OpenShift, another IaC tool? Request a setup ↗. Never paste license keys, passwords, tokens or database URLs in an issue.
Other setups
Docker Compose on one machine · DigitalOcean (Terraform) · Google Cloud (Terraform, Cloud Run + Cloud SQL) · Azure (Terraform, Container Apps + PostgreSQL Flexible Server) · Kubernetes (Helm) · Kubernetes (plain kubectl) · Air-gapped (no internet) · Linux without Docker (systemd)