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.57k stars 3.88k forks source link

`aws_stepfunctions`: Programmatic IO #29482

Open JonathanWoollett-Light opened 6 months ago

JonathanWoollett-Light commented 6 months ago

Describe the feature

One of the most frustrating areas when defining step functions is defining how values are passed between states (e.g. JsonPath).

This could be greatly improved if states had properties to get their input and outputs.

Use Case

const myPass = new sfn.Pass(this, 'MyPassState', {
    parameters: {
        'someValue.$': '$$.Execution.Input'
    },
});
const mySfn = new sfn.StateMachine(this, 'MyStepFunction', {
    definition: myPass,
    timeout: cdk.Duration.hours(24)
});

Proposed Solution

const mySfn = new sfn.StateMachine(this, 'MyStepFunction', {
    timeout: cdk.Duration.hours(24)
});
const myPass = new sfn.Pass(this, 'MyPassState', {
    parameters: {
        'myValue': mySfn.input,
    },
});
mySfn.definition = myPass;

Other Information

Fixing this might be difficult, I just want to highlight this problem and see if others also experience it. Any programmatic solution would be a great improvement over using JsonPaths directly.

Acknowledgements

CDK version used

2.132.1

Environment details (OS name and version, etc.)

Linux 6.5.0-21-generic #21~22.04.1-Ubuntu x86_64 GNU/Linux

tim-finnigan commented 6 months ago

Thanks for the feature request. Linking aws_stepfunctions documentation for reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions-readme.html

Please feel free to share more details regarding your use case and others can 👍 this issue or add more information as well.