Skip to content

How do you manage Batch Job Descriptions when the ECR container image changes?

0

I have several AWS Batch Job Definitions that rely on container images stored in ECR. My problem is that whenever I update the container images in ECR I have to update the Job Definitions as well.

My first instinct was to use image tags (development, testing, release, etc.) and hard code my Job Definition to point to the correct tag. However, all the "best practices" documents say that your ECR repos should be immutable, which makes it impossible to re-tag an image as it moves through the application lifecycle. (development-->testing, testing-->release).

Another option (which is what I'm using) is to update Job Definitions every time the ECR image gets rebuilt. This works but it feels like a game of cat-and-mouse where I have to make sure that I find and update everywhere that image is used.

I've only started with ECS / Batch but already it feels like trying to keep everything updated and pointed in the right direction is a losing proposition. Am I missing something? Is there an easier way? How are you managing your Batch Job Descriptions when it comes to ECR image update?

UPDATE: this seems to be a related question but it doesn't really provide an answer - https://repost.aws/questions/QUrBwePY4tSeut4XFlQsyhAQ/recommended-batch-automated-workflow-for-updating-docker-containers

2 Answers
2
Accepted Answer

Hello.

Another option (which is what I'm using) is to update Job Definitions every time the ECR image gets rebuilt. This works but it feels like a game of cat-and-mouse where I have to make sure that I find and update everywhere that image is used.

I often update using this method.
It is also possible to automate this by introducing CI/CD and updating the task definition when the container image is pushed to ECR.
CodePipeline can launch CI/CD using ECR as a source.
https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-ECR.html

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • We are using GitHub Actions for our CI/CD and I'm using "aws batch describe-job-definitions" and "aws batch register-job-definition" CLI commands to do most of the heavy lifting. It works but it's a bit clumsy and requires us to keep track of every single use of that container image in AWS and update it every time a new image it pushed to ECR. There seems like there should be a better way.

0

You can use a use a mutable tag like :latest in your Job Definitions for the container image: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/<repository_name>:latest

Pros:

  • No need to update Job Definitions after each image build.
  • Simplifies CI/CD pipelines, especially for dev/test environments.

Cons:

  • Loss of immutability — you can't guarantee which image was used for a specific job run.
  • Harder to trace/debug if something breaks due to a silent image update.

Using :latest is fine for non-critical environments, but for production workloads, consider immutable tags with automation to keep things traceable and maintainable.

I came here looking for a strategy because I don’t want to use latest either. I’m planning to have my pipeline create a new Job Definition for each image version but was looking for best practices and a pattern. I think part of the difference is that I use a separate ECR repo for each environment (dev/test/prod), so I don’t rely on re-tagging images. Just thought I’d share in case it helps someone else exploring options.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.