cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

Option to not deregister prior AWS Batch Job Definition revisions

Open ininrobu opened this issue 2 years ago • 4 comments

Name of the resource

AWS::Batch::JobDefinition

Resource name

No response

Description

Add an option to the CloudFormation definition of AWS Batch Job Definitions that will prevent updates which result in a new revision from deregistering the previous revision. At a minimum a simple boolean, conceptually something like LeaveOldRevisionsActive, would work. That puts the onus on clients to handle cleaning up older revisions though. Ideally it would include a count of the number of prior revisions to leave active, which would allow revisions to naturally be deregistered and eventually cleaned up without client involvement.

Other Details

We adhere to a strict rule of immutable deploys, which means a given version of a deployed service always launches Batch jobs using a specific Job Definition revision. When we deploy a new version of a service there is a window of time between when the CloudFormation stack is updated and the new service code is active (and the old service code inactive) where launching jobs will fail because the CloudFormation update has deregistered the job definition revision that the old service code is reliant upon.

ininrobu avatar Aug 01 '23 14:08 ininrobu

Very surprising this issue hasn’t been addressed by AWS. What is the purpose of revisions if only the last one is usable?

nywhere avatar Apr 04 '25 05:04 nywhere

We're facing the exact same issue.

tpt-ntardieu avatar Apr 09 '25 07:04 tpt-ntardieu

we have the same issue too

prtlgncscottshealy avatar Oct 07 '25 20:10 prtlgncscottshealy

AWS Batch has released the ability to skip deregistering the previous revision on update events for AWS::Batch::JobDefinition resources.

This feature can be utilized via these properties: ResourceRetentionPolicy and its child attribute SkipDeregisterOnUpdate.

Here are the CFN docs on these properties:

  • https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-batch-jobdefinition.html#cfn-batch-jobdefinition-resourceretentionpolicy
  • https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-batch-jobdefinition-resourceretentionpolicy.html

PravinthAWS avatar Nov 04 '25 05:11 PravinthAWS