I'm submitting a ...
What is the current behavior?
Create a simple Step Function with a Lambda function and a Fargate task:
βββββ βββββββββββ
β Ξ» βββββΆβ Fargate β
βββββ βββββββββββ
The lambda function produces the following output:
{
"runId": "123456789"
}
This unique ID needs to be picked up by the Fargate task. This allows us to run several step functions in parallel, re-run them etc. The only way I found to pass an input to en ECS task in step function is the ContainerOverride
class with a list of TaskEnvironmentVariable
objects. I'd expect to pass the runId
like this:
tasks.RunEcsFargateTask(
cluster=ecs_cluster,
task_definition=fargate_task_definition,
assign_public_ip=True,
container_overrides=[
targets.ContainerOverride(
container_name='AnomalyDetectionContainer',
environment=[
tasks.TaskEnvironmentVariable(
name='RUN_ID',
value='$.runId'
)
]
)
]
)
Documentation also mentions valuePath
but that does not work (even Pythonic value_path
version).
The Fargate task gets RUN_ID
environment variable with value $.runId
.
The Fargate task gets RUN_ID
environment variable with value 123456789
.
What is the motivation / use case for changing the behavior or adding this feature?
There seems to be no way to pass an input to ECS tasks in Step Functions. S3 won't work, because we're running several step functions in parallel and the values can't mix up.
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
I just learned about the Data class. Here's how it works:
tasks.RunEcsFargateTask(
cluster=ecs_cluster,
task_definition=fargate_task_definition,
assign_public_ip=True,
container_overrides=[
targets.ContainerOverride(
container_name='AnomalyDetectionContainer',
environment=[
tasks.TaskEnvironmentVariable(
name='RUN_ID',
value=sfn.Data.string_at('$.runId')
)
]
)
]
)
I struggled with this, too. It could have been more user-friendly to use valuePath
and namePath
as suggested in the inline docs:
@pepastach so I think this issue should be re-opened.
The doc is misleading.
Agree that sfn.Data.string_at('$.runId') is ugly.
Most helpful comment
The doc is misleading.
Agree that sfn.Data.string_at('$.runId') is ugly.