What's the easiest way to update my ECS service when a new container is pushed to ECR?
Asked by
Jemsy
I'm trying to figure out the simplest method to automatically update my ECS service every time I push a new container to ECR. I've come across several options like Step Functions, CI/CD pipelines, and EventBridge, but I'm looking for the most straightforward solution. Since I typically use the #latest tag, I find myself needing to manually update the service or trigger a new deployment each time. Is there a more efficient way to handle this?
Answers
In an ideal setup, this should be handled through CI/CD so you can maintain control over the deployment process.
Reply to this answer
You could also specify a unique tag with a hash in your task definition instead of just using 'latest'. Plus, consider setting up a git sync so your stack updates automatically whenever you push changes to your git template. That way, you can manage separate branches for production, staging, and development, making deployments much smoother.
Reply to this answer
I just manually force a new deployment for my development environment whenever I push updates to ECR. Itโs simple for smaller projects.
Reply to this answer
They actually have this feature built into AWS App Runner, which is a more managed service. That could be a sign of where they draw the line between managed functions and manual processes.
Reply to this answer
The reality is that ECS needs to be told to reload the container, as it doesn't do this automatically. Using EventBridge could be your best bet for a hands-off approach, since it doesnโt depend on a CI/CD system. If AWS ever adds an auto-reload feature for ECS, that's likely how it would work behind the scenes.
Reply to this answer
I usually manage it through CI/CD myself. If you're consistently using the latest tag, a new deployment can be forced easily on your service. Alternatively, you could set up a Lambda function or CloudFormation stack that triggers on new image uploads to automatically update your task definition with the new image tag.
Reply to this answer
Add your answer
Answers are reviewed before publication.
PAUSE_button: Using Lambda to automatically trigger a new deployment when there are new changes in ECR sounds like a solid approach! I havenโt tried it yet myself.