(stepfunctions): allow intrinsic functions for JsonPath.list_at
Description
Currently the Step functions JsonPath.list_at values must either be exactly equal to '$' or start with '$.'. But this doesn't allow intrinsic functions and can thereby also start with 'States.Array'.
task = sfn_tasks.BatchSubmitJob(self, id,
job_definition_arn=self.job_definition.job_definition_arn,
job_name=id,
job_queue_arn=self.job_queue.job_queue_arn,
container_overrides={
"command" : sfn.JsonPath.list_at("States.Array('StaticValue1',$.DynamicValue2,'StaticValue3')")
}
)
https://github.com/aws/aws-cdk/blob/919605a781ac02393559fd96cbd8c136f87bce14/packages/%40aws-cdk/aws-stepfunctions/lib/fields.ts#L228-L232
Use Case
allow intrinsic functions and can thereby also start with 'States.Array'
Proposed Solution
From: https://github.com/aws/aws-cdk/blob/919605a781ac02393559fd96cbd8c136f87bce14/packages/%40aws-cdk/aws-stepfunctions/lib/fields.ts#L228-L232
To:
function validateDataPath(path: string) {
if (path !== '$'
&& !path.startsWith('$.')
&& ['Format','Array'].every(fn => !path.startsWith(`States.${fn}`))) {
throw new Error("Data JSON path values must either be exactly equal to '$' or start with '$.'");
}
}
Other information
No response
Acknowledge
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Marking this as effort small because the fix proposed is small, but it looks like the reason why we haven't yet supported ASL intrinsic functions as a whole is because there likely is some design work involved in getting that support right.
It's on my radar, hence the p1, but I haven't gotten to it yet.
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
Can this issue be looked into? I happened to run across the same issue and the only solution I could find was replacing the code with suggested solution.
For those still facing this issue, it seems that using JsonPath.objectAt pointing to the array's Json Path does the trick. That may be better than having to tune the CDK's code.
For those still facing this issue, it seems that using
JsonPath.objectAtpointing to the array's Json Path does the trick. That may be better than having to tune the CDK's code.
Do you want to elaborate?