Back to Slides
Makers  /  Cloud Engineering

Updating a Live
Fargate Deployment

From a local code change to a running update on AWS

Docker Amazon ECR Amazon ECS AWS Fargate eu-west-2

Johnny Geambasu    johnnygeambasu.com

The Update Pipeline

Fargate doesn't watch your files. Every code change must travel this full path to go live.

Edit Code locally
-->
Rebuild new image tag
-->
Auth ECR docker login
-->
Push to ECR
-->
Task Def new revision
-->
Update service
-->
New IP :3030
Key point: Each step depends on the previous one. Skip any step and the change won't reach Fargate.

Step 1  /  Edit the Code

index.html updated in editor templates/index.html — updated message

What changed

  • Opened templates/index.html
  • Updated the <h1> and <p> text
  • Saved the file
This is a local change only. The running Fargate task has no idea it happened yet. Nothing on AWS has changed.
Make sure you are in the right folder. All commands from this point must be run from inside contain-my-flask/ where the Dockerfile lives.

Step 2  /  Rebuild the Image

STEP 2
docker buildx build \
  --platform linux/amd64 \
  -t contain-my-flask:1.0.1 .
Note the space before the dot. The . at the end tells Docker to look for the Dockerfile in the current directory. A missing space causes an error.
Use a new tag. Bump the version (:1.0.0 to :1.0.1) so you can always roll back to a previous image if something breaks.
docker buildx build output in terminal Terminal output — build finished in 6.4s

Step 3  /  Authenticate and Push to ECR

Authenticate Docker with ECR

aws ecr get-login-password \
  --region eu-west-2 \
  | docker login \
    --username AWS \
    --password-stdin \
    664047078509.dkr.ecr.eu-west-2.amazonaws.com
Login Succeeded means Docker can now push to your ECR registry.

Tag and Push

# Tag with the ECR URI
docker tag contain-my-flask:1.0.1 \
  664047078509.dkr.ecr.eu-west-2\
  .amazonaws.com/contain-my-flask:1.0.1

# Push to ECR
docker push \
  664047078509.dkr.ecr.eu-west-2\
  .amazonaws.com/contain-my-flask:1.0.1
Why tag? Docker needs the full ECR URI to know where to send the image. The tag command adds that address as an alias — the image itself doesn't move until you push.

Step 4  /  Update the Task Definition

Why this step exists

The ECS Task Definition is the blueprint that tells Fargate which image to run. It points to a specific image tag. Just pushing a new image to ECR doesn't change what Fargate runs — you have to update the blueprint too.

Common mistake: Running --force-new-deployment without updating the task definition restarts the service but pulls the old image. The change never goes live.

In the AWS Console

  • ECS  →  Task Definitions  →  flask-task
  • Click Create new revision
  • Find the container definition
  • Change the image tag from :1.0.0 to :1.0.1
  • Click Create
Result: A new revision is created. ECS keeps all previous revisions so you can roll back at any time.

Step 5  /  Update the Service and Find the New IP

Update the service

In the Console: ECS  →  Clusters  →  flask-cluster  →  flask-service  →  Update. Point to the new task definition revision, then click Update.

Fargate assigns a new public IP every time it starts a new task. You must look it up after each deployment.
# 1. Get the task ARN
aws ecs list-tasks \
  --cluster flask-cluster \
  --region eu-west-2 \
  --query "taskArns[0]" --output text

# 2. Get the network interface ID
aws ecs describe-tasks \
  --cluster flask-cluster \
  --tasks <task-arn> \
  --region eu-west-2 \
  --query "tasks[0].attachments[0].details"

# 3. Get the public IP
aws ec2 describe-network-interfaces \
  --network-interface-ids <eni-id> \
  --region eu-west-2 \
  --query "NetworkInterfaces[0].Association.PublicIp" \
  --output text

Check deployment status

aws ecs describe-services \
  --cluster flask-cluster \
  --service flask-service \
  --region eu-west-2 \
  --query "services[0].deployments"
Watch for: rolloutState: COMPLETED and runningCount: 1 before visiting the new IP.
$ curl http://13.42.63.43:3030/
It works. And not just on my machine.

It's Live

Live app running on Fargate at 13.42.63.43:3030

http://13.42.63.43:3030  /  Running on AWS Fargate  /  eu-west-2

Key Takeaways

01

Fargate doesn't watch your files. A code change does nothing until you rebuild the image, push it to ECR, update the task definition, and redeploy the service.

02

Always use a new image tag. Bumping the version (:1.0.0 to :1.0.1) gives you a clear history and the ability to roll back instantly.

03

The IP changes every deployment. Fargate assigns a new public IP each time a task restarts. Always look it up after a deployment.

04

Force-new-deployment alone is not enough. It restarts the service but uses the same image. You must update the task definition to a new revision first.

Thank you

Questions?

Docker  /  Amazon ECR  /  Amazon ECS  /  AWS Fargate

johnnygeambasu.com

← → navigate · Esc overview