Skip to content

Commit

Permalink
fix(stepfunctions): Map state does not render JSON paths from state i…
Browse files Browse the repository at this point in the history
…nput (aws#9008)

The Map state property parameters support JSON path, but
the CDK does not render these as it does with other properties
that support using JSON path.

This change renders the properties so that Json path strings
which start with $. have their keys adjusted to reference the
state input field they reference.

Closes aws#8992 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
shivlaks authored Jul 14, 2020
1 parent 8c01420 commit 767da12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-stepfunctions/lib/states/map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as cdk from '@aws-cdk/core';
import { Chain } from '../chain';
import { FieldUtils } from '../fields';
import { StateGraph } from '../state-graph';
import { CatchProps, IChainable, INextable, RetryProps } from '../types';
import { StateType } from './private/state-type';
Expand Down Expand Up @@ -156,6 +157,7 @@ export class Map extends State implements INextable {
ResultPath: renderJsonPath(this.resultPath),
...this.renderNextEnd(),
...this.renderInputOutput(),
...this.renderParameters(),
...this.renderRetryCatch(),
...this.renderIterator(),
...this.renderItemsPath(),
Expand Down Expand Up @@ -185,4 +187,13 @@ export class Map extends State implements INextable {
ItemsPath: renderJsonPath(this.itemsPath),
};
}

/**
* Render Parameters in ASL JSON format
*/
private renderParameters(): any {
return FieldUtils.renderObject({
Parameters: this.parameters,
});
}
}
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-stepfunctions/test/map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('Map State', () => {
'Map State': {
Type: 'Map',
End: true,
Parameters: { foo: 'foo', bar: '$.bar' },
Parameters: {
'foo': 'foo',
'bar.$': '$.bar',
},
Iterator: {
StartAt: 'Pass State',
States: {
Expand Down

0 comments on commit 767da12

Please sign in to comment.