Skip to content

(aws-stepfunctions-tasks): (Batch SubmitJob automatically adds a containerOverrides even with an ECS multi container Batch ) #36273

@cbm-afoulfoin

Description

@cbm-afoulfoin

Describe the bug

Considering an AWS batch job definition that defines two containers within ecsProperties:

const jobDefinition = new CfnJobDefinition(scope, `job-definition-${name}`, {
        containerProperties: {
            ecsProperties: {
            ....
            }
       }
})

We try to launch that job throught AWS step function:

const batchJobTask = new tasks.BatchSubmitJob(scope, `${app}-${name}-job-task`, {
        jobName: `${app}-${name}-job`,
        ...
        stateName: 'ExecuteBatchJob',
      });

Step function will fails with the following error : Container overrides should not be set for ecsProperties jobs. (Service: AWSBatch; Status Code: 400; Error Code: ClientException; Request ID: 36d5ba3a-466d-4ed8-b559-7a3193c0970b; Proxy: null)

It seems that AWS Step function automatically adds this bloc in the batch definition:

"ContainerOverrides":{
    "Environment": [
      {
        "Name": "MANAGED_BY_AWS",
        "Value": "STARTED_BY_STEP_FUNCTIONS"
      }
    ]
  }

But ContainerOverrides seems incompatibale with a job that uses EcsProperties, making the Step failing.

Another example of user having the same issue: https://repost.aws/questions/QUYUtrKcPGRf-Rj1m1dXJH1Q/aws-batch-running-ecsproperties-job-with-aws-stepfunction

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

The BatchSubmitJob should work with AWS Batch jobs that define ecsProperties

Current Behavior

The BatchSubmitJob doesn't work with AWS Batch jobs that define ecsProperties

Reproduction Steps

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.212.0

AWS CDK CLI version

2.1020.0

Node.js Version

22

OS

Windows

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions