diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts b/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts index dfc9f8f75c246..e99559edaab43 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/states/state.ts @@ -24,6 +24,16 @@ export interface StateProps { */ inputPath?: string; + /** + * Parameters pass a collection of key-value pairs, either static values or JSONPath expressions that select from the input. + * + * @see + * https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-parameters + * + * @default No parameters + */ + parameters?: { [name: string]: any }; + /** * JSONPath expression to select part of the state to be the output to this state. * @@ -112,6 +122,7 @@ export abstract class State extends cdk.Construct implements IChainable { // pragmatic! protected readonly comment?: string; protected readonly inputPath?: string; + protected readonly parameters?: object; protected readonly outputPath?: string; protected readonly resultPath?: string; protected readonly branches: StateGraph[] = []; @@ -144,6 +155,7 @@ export abstract class State extends cdk.Construct implements IChainable { this.comment = props.comment; this.inputPath = props.inputPath; + this.parameters = props.parameters; this.outputPath = props.outputPath; this.resultPath = props.resultPath; } @@ -297,11 +309,12 @@ export abstract class State extends cdk.Construct implements IChainable { } /** - * Render InputPath/OutputPath in ASL JSON format + * Render InputPath/Parameters/OutputPath in ASL JSON format */ protected renderInputOutput(): any { return { InputPath: renderJsonPath(this.inputPath), + Parameters: this.parameters, OutputPath: renderJsonPath(this.outputPath), }; } diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts b/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts index b540dacf30787..a6ed6025de560 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts @@ -34,6 +34,16 @@ export interface TaskProps { */ inputPath?: string; + /** + * Parameters pass a collection of key-value pairs, either static values or JSONPath expressions that select from the input. + * + * @see + * https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-parameters + * + * @default No parameters + */ + parameters?: { [name: string]: any }; + /** * JSONPath expression to select part of the state to be the output to this state. * diff --git a/packages/@aws-cdk/aws-stepfunctions/test/test.state-machine-resources.ts b/packages/@aws-cdk/aws-stepfunctions/test/test.state-machine-resources.ts index 6484828c19ec9..b3adf4581b955 100644 --- a/packages/@aws-cdk/aws-stepfunctions/test/test.state-machine-resources.ts +++ b/packages/@aws-cdk/aws-stepfunctions/test/test.state-machine-resources.ts @@ -91,6 +91,48 @@ export = { statistic: 'Sum' }); + test.done(); + }, + + 'Task should render InputPath / Parameters / OutputPath correctly'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const task = new stepfunctions.Task(stack, 'Task', { + resource: new FakeResource(), + inputPath: "$", + outputPath: "$.state", + parameters: { + "input.$": "$", + "stringArgument": "inital-task", + "numberArgument": 123, + "booleanArgument": true, + "arrayArgument": ["a", "b", "c"] + } + }); + + // WHEN + const taskState = task.toStateJson(); + + // THEN + test.deepEqual(taskState, { End: true, + Retry: undefined, + Catch: undefined, + InputPath: '$', + Parameters: + { 'input.$': '$', + 'stringArgument': 'inital-task', + 'numberArgument': 123, + 'booleanArgument': true, + 'arrayArgument': [ 'a', 'b', 'c' ] }, + OutputPath: '$.state', + Type: 'Task', + Comment: undefined, + Resource: 'resource', + ResultPath: undefined, + TimeoutSeconds: undefined, + HeartbeatSeconds: undefined + }); + test.done(); } };