aws / aws/aws-cdk

aws-stepfunctions-tasks: Request feature for EvaluateExpression to support expression.$

Open
#23,631 0 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-stepfunctions-tasks feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

Currently, EvaluateExpression is rendering the parameters with key `expression` instead of `expression.$`. Although the class itself support simple states path computation to do something like
```
expression: "$.a + $.b"
```
but it could extends it could extends its potential to replace some of the simple lambda functions if EvaluateExpression can evaluate intrinsic functions like `States.Format`, etc.

### Use Case

I am trying to write javascript code block along with data from JSON paths using EvaluateExpression. For example, I want to do below
```
expression: `
States.Format('
const objectA = {};
const objectB = {};
... // some computation to get value'
, States.JsonToString($.a), States.JsonToString($.b))
`
```
Above allows us to quickly create script inside CDK without creating a separate lambda function.
However, currently EvaluationExpression will not render intrinsic functions like `States.Format` or `States.JsonToString`.

### Proposed Solution

Within [evaluate-expression.ts](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-stepfunctions-tasks/lib/evaluate-expression.ts#L87), we can possibly render the parameter using key `expression.$` instead of `expression` when intrinsic functions are detected by regex.

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.54.0

### Environment details (OS name and version, etc.)

macOS

Contributor guide

Open the contributing guide

Research direction

Start with packages/@aws-cdk/aws-stepfunctions-tasks/lib/evaluate-expression.ts around line 87 and inspect how EvaluateExpression renders its parameters. Confirm the expected handling of intrinsic functions such as States.Format and States.JsonToString; done means those cases render with expression.$ while existing simple expressions continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.