Research Summary: If you check the events in the CloudTrail you can easily find the deregister-job-definition
events getting triggered. That causes the latest revision of the job-definition
to go into inactive
state and eligible for deletion after 90 days.
Further, CloudTrail Event's could help you to trace the issue was coming from the terraform.
The fix is to explicitly add deregister_on_new_revision
in the aws_batch_job_definition
resource block of your terraform like below:
resource "aws_batch_job_definition" "test" {
name = "tf_test_batch_job_definition"
type = "container"
..
deregister_on_new_revision = false
}
Description:
deregister_on_new_revision
- (Optional) When updating a job definition a new revision is created. This parameter determines if the previous version is deregistered (INACTIVE
) or leftACTIVE
. Defaults to true.