Run a one-off migration container on ECS before each deploy. What pattern?
IntermediateScenarioECS, EKS, Lambda and ECR
Answer
Situation read → Run a standalone task as a pipeline step.
What I'd do →
aws ecs run-task --cluster prod --task-definition migrate --launch-type FARGATE --network-configuration ...- Wait:
aws ecs wait tasks-stopped --cluster prod --tasks <arn> - Check exit code via
describe-tasks - Fail the pipeline on non-zero
- Then deploy the service
Why → Separating migration from service start avoids race conditions among replicas.
Interview tip → Use backward-compatible migrations.
More on ECS, EKS, Lambda and ECR
ECS on Fargate or on EC2: how do you choose?BeginnerDeploy a containerized API on ECS behind an ALB. What are the building blocks?BeginnerAn ECS service deployment is stuck, tasks start and stop repeatedly. How do you debug?IntermediateRoll out a new ECS service version with canary and automatic rollback.IntermediateEKS pods need access to S3 without node-level permissions. How?IntermediateUpgrade an EKS cluster from 1.31 to 1.33 safely.Intermediate