AWS ECS Notes

ECS Fargate is the AWS no-K8s path; the image and env contract are identical, ECS is just the scheduler. On EKS, prefer the Helm chart. This page covers the ECS-specific glue: task definition, ALB path split, RDS, and the migration one-shot.

Image registry

Fargate can pull directly from Docker Hub, but mirror to ECR for in-region pull latency, immutable-tag policies, and scan-on-push:

aws ecr get-login-password --region us-east-1 | \\
  docker login --username AWS --password-stdin <ACCOUNT>.dkr.ecr.us-east-1.amazonaws.com

docker pull simchasolutions/db-studio:1.0.1
docker tag simchasolutions/db-studio:1.0.1 <ACCOUNT>.dkr.ecr.us-east-1.amazonaws.com/simcha-db-studio:1.0.1
docker push <ACCOUNT>.dkr.ecr.us-east-1.amazonaws.com/simcha-db-studio:1.0.1

Task definition essentials

Migrations on ECS

Set MIGRATE_ON_BOOT=false on the service and gate the schema change with a one-shot task: a separate task definition on the same image with the command overridden to node dist/server/database/migrate.js. In the pipeline, aws ecs run-task, poll to a successful STOPPED exit (code 0), then update the service. This avoids the multi-task migration race and stops the deploy if the migration fails.

ALB configuration

RDS for the metadata database

Updating the service

# Mirror the new tag into your registry
docker pull simchasolutions/db-studio:1.0.2
docker tag simchasolutions/db-studio:1.0.2 <ACCOUNT>.dkr.ecr.us-east-1.amazonaws.com/simcha-db-studio:1.0.2
docker push <ACCOUNT>.dkr.ecr.us-east-1.amazonaws.com/simcha-db-studio:1.0.2

# Run the migration task and wait
aws ecs run-task --task-definition simcha-db-studio-migrate:<rev> ...

# Update the app service to the new task definition revision
aws ecs update-service \\
  --cluster <cluster> --service simcha-db-studio \\
  --task-definition simcha-db-studio:<new-rev> \\
  --force-new-deployment

Rolling deploys with maximumPercent: 200 / minimumHealthyPercent: 100 give zero-downtime updates.