Reputation: 31
I'm trying to set up an EMR step from the CDK (typescript), using a variable from the state context object as a parameter, but I can't get it to work.
Here's what I tried:
const emrTask = new EmrAddStep(
stack,
name,
{
name: name,
jar: jar,
args: [
'--arg_1',
'$$.Execution.StartTime',
],
clusterId: clusterId,
}
);
During the state run $$.Execution.StartTime
does not get replaced by the actual value.
I also tried this:
const emrTask = new EmrAddStep(
stack,
name,
{
name: name,
jar: jar,
args: [
'--arg_1',
JsonPath.stringAt('$$.Execution.StartTime')
],
clusterId: clusterId,
}
);
But I get this error:
Error: Cannot use JsonPath fields in an array, they must be used in objects
Upvotes: 3
Views: 3567
Reputation: 1985
You can use an EvaluateExpression
task to do that
new tasks.EvaluateExpression(stack, name, {
expression: `['--arg_1', $$.Execution.StartTime]`,
resultPath: '$.emrArgs'
});
And then you can adapt your task creation like the following
const emrTask = new EmrAddStep(
stack,
name,
{
name: name,
jar: jar,
args: sfn.JsonPath.listAt('$.emrArgs'),
clusterId: clusterId,
}
);
Could not find a way to do it in a single task though.
Upvotes: 2