aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.69k stars 3.93k forks source link

[aws-stepfunctions-tasks] Batch SubmitJob: Support TaskInput on all Parameters supported by service integration #10708

Open elemakil opened 4 years ago

elemakil commented 4 years ago

According to the documentation of the AWS Batch service integration pattern for AWS StepFunctions (link), the service integration pattern supports the following parameters of the AWS Batch job:

As far as I can tell, currently (v1.66.0), the aws-stepfunctions-tasks.BatchSubmitJob CDK construct does not support passing data into the AWS Batch Service from the AWS StepFunction event object using the JSON path for any of the above parameters except for the "Parameters" parameter (sorry for the confusing naming...) through the payload construct prop.

As the service integration pattern supports all these additional parameters with JSON path, it seems sensible for the CDK construct to also support this feature.

Use Case

I would like to be able to configure the supported AWS Batch service integration parameters using the event object passed into the stepfunction task.

To me, this is particularly useful for the JobName, JobQueue, JobDefinition parameters as well as the ContainerOverrides parameter, whose nested elements allow to override the actual command executed by the AWS batch job.

Proposed Solution

In addition to the current data type, the construct props which map to AWS StepFunctions service integration parameters should accept a aws-stepfunctions.TaskInput object. Depending on the type of the supplied data, a parameter is filled in either using the current behaviour or a JSON path according to "Pass Parameters to a Service API" is constructed and rendered.

Other


This is a :rocket: Feature Request

nodesmichael commented 3 years ago

We need this too. Specifically for containerOverrides.environment. But I guess containerOverrides alone could do the trick.

obenshaindw commented 2 years ago

We also ran into this issue on a recent project, and it took some time to come up with workarounds. The CDK typing for ContainerOverrides.Environment prevents the use of JSON Task Input expression for the entire list of environment variables.

  1. Using sfn.CustomState and specifying all the Parameters as JSON Task Input expressions and wrapping that in a sfn.Chain.
  2. Defining a sfn.TaskStateBase class and defining a new SubmitBatchJob class that extends the sfn.TaskStateBase class; setting the parameters from properties to that class. Similar to this solution