Skip to content

Commit 5b68328

Browse files
marciocadevmrgrain
authored andcommitted
fix(stepfunctions): JsonPath.listAt does not accept strings starting with $[ (aws#22472)
`JsonPath.listAt` doest not accept strings starting with `$[`. When going through a parallel task, the result is an array and to work with it, it needs to be referenced through strings starting with `$[` This problem particularly affects cases where we want to work with String Sets in DynamoDB where the `DynamoAttributeValue.fromStringSet` function expects an array via the `JsonPath.listAt` function Closes aws#22471 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4c65ce6 commit 5b68328

22 files changed

+1439
-4
lines changed

Diff for: packages/@aws-cdk/aws-stepfunctions-tasks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
},
8080
"license": "Apache-2.0",
8181
"devDependencies": {
82-
"@aws-cdk/integ-tests": "0.0.0",
8382
"@aws-cdk/assertions": "0.0.0",
8483
"@aws-cdk/aws-apigatewayv2": "0.0.0",
8584
"@aws-cdk/aws-apigatewayv2-integrations": "0.0.0",
@@ -91,6 +90,7 @@
9190
"@aws-cdk/aws-sns-subscriptions": "0.0.0",
9291
"@aws-cdk/cdk-build-tools": "0.0.0",
9392
"@aws-cdk/integ-runner": "0.0.0",
93+
"@aws-cdk/integ-tests": "^0.0.0",
9494
"@aws-cdk/pkglint": "0.0.0",
9595
"@types/jest": "^27.5.2",
9696
"jest": "^27.5.1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as ddb from '@aws-cdk/aws-dynamodb';
2+
import * as sfn from '@aws-cdk/aws-stepfunctions';
3+
import * as cdk from '@aws-cdk/core';
4+
import * as integ from '@aws-cdk/integ-tests';
5+
import * as tasks from '../../lib';
6+
7+
const app = new cdk.App();
8+
const stack = new cdk.Stack(app, 'stringset-after-parallel');
9+
10+
const table = new ddb.Table(stack, 'Table', {
11+
partitionKey: { name: 'pk', type: ddb.AttributeType.STRING },
12+
removalPolicy: cdk.RemovalPolicy.DESTROY,
13+
});
14+
15+
const passPK = new sfn.Pass(stack, 'passPK', {
16+
parameters: { 'pk.$': '$.pk' },
17+
});
18+
const passStringSet = new sfn.Pass(stack, 'PassStringSet', {
19+
parameters: { 'stringset.$': '$.stringset' },
20+
});
21+
22+
const parallel = new sfn.Parallel(stack, 'Parallel', {
23+
resultPath: '$',
24+
});
25+
parallel.branch(passPK)
26+
.branch(passStringSet);
27+
28+
const putItem = new tasks.DynamoPutItem(stack, 'PutItem', {
29+
table: table,
30+
item: {
31+
pk: tasks.DynamoAttributeValue.fromString('$[0].pk'),
32+
stringset: tasks.DynamoAttributeValue.fromStringSet(sfn.JsonPath.listAt('$[1].stringset')),
33+
},
34+
});
35+
36+
const definition = sfn.Chain.start(parallel).next(putItem);
37+
38+
new sfn.StateMachine(stack, 'StateMachine', {
39+
definition: definition,
40+
});
41+
42+
new integ.IntegTest(app, 'StringSetAfterParallel', {
43+
testCases: [stack],
44+
});
45+
46+
app.synth();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "21.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "StringSetAfterParallelDefaultTestDeployAssert649ABBB9.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"21.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "21.0.0",
3+
"testCases": {
4+
"StringSetAfterParallel/DefaultTest": {
5+
"stacks": [
6+
"stringset-after-parallel"
7+
],
8+
"assertionStack": "StringSetAfterParallel/DefaultTest/DeployAssert",
9+
"assertionStackName": "StringSetAfterParallelDefaultTestDeployAssert649ABBB9"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"version": "21.0.0",
3+
"artifacts": {
4+
"Tree": {
5+
"type": "cdk:tree",
6+
"properties": {
7+
"file": "tree.json"
8+
}
9+
},
10+
"stringset-after-parallel.assets": {
11+
"type": "cdk:asset-manifest",
12+
"properties": {
13+
"file": "stringset-after-parallel.assets.json",
14+
"requiresBootstrapStackVersion": 6,
15+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
16+
}
17+
},
18+
"stringset-after-parallel": {
19+
"type": "aws:cloudformation:stack",
20+
"environment": "aws://unknown-account/unknown-region",
21+
"properties": {
22+
"templateFile": "stringset-after-parallel.template.json",
23+
"validateOnSynth": false,
24+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
25+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/30011aca79761d24d65d6f3f8af03bf4a54f58ac4a5fdbadcb2d1fb0fa225066.json",
27+
"requiresBootstrapStackVersion": 6,
28+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
29+
"additionalDependencies": [
30+
"stringset-after-parallel.assets"
31+
],
32+
"lookupRole": {
33+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
34+
"requiresBootstrapStackVersion": 8,
35+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
36+
}
37+
},
38+
"dependencies": [
39+
"stringset-after-parallel.assets"
40+
],
41+
"metadata": {
42+
"/stringset-after-parallel/Table/Resource": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "TableCD117FA1"
46+
}
47+
],
48+
"/stringset-after-parallel/StateMachine/Role/Resource": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "StateMachineRoleB840431D"
52+
}
53+
],
54+
"/stringset-after-parallel/StateMachine/Role/DefaultPolicy/Resource": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "StateMachineRoleDefaultPolicyDF1E6607"
58+
}
59+
],
60+
"/stringset-after-parallel/StateMachine/Resource": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "StateMachine2E01A3A5"
64+
}
65+
],
66+
"/stringset-after-parallel/Service-principalMap": [
67+
{
68+
"type": "aws:cdk:logicalId",
69+
"data": "ServiceprincipalMap"
70+
}
71+
],
72+
"/stringset-after-parallel/BootstrapVersion": [
73+
{
74+
"type": "aws:cdk:logicalId",
75+
"data": "BootstrapVersion"
76+
}
77+
],
78+
"/stringset-after-parallel/CheckBootstrapVersion": [
79+
{
80+
"type": "aws:cdk:logicalId",
81+
"data": "CheckBootstrapVersion"
82+
}
83+
]
84+
},
85+
"displayName": "stringset-after-parallel"
86+
},
87+
"StringSetAfterParallelDefaultTestDeployAssert649ABBB9.assets": {
88+
"type": "cdk:asset-manifest",
89+
"properties": {
90+
"file": "StringSetAfterParallelDefaultTestDeployAssert649ABBB9.assets.json",
91+
"requiresBootstrapStackVersion": 6,
92+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
93+
}
94+
},
95+
"StringSetAfterParallelDefaultTestDeployAssert649ABBB9": {
96+
"type": "aws:cloudformation:stack",
97+
"environment": "aws://unknown-account/unknown-region",
98+
"properties": {
99+
"templateFile": "StringSetAfterParallelDefaultTestDeployAssert649ABBB9.template.json",
100+
"validateOnSynth": false,
101+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
102+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
103+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
104+
"requiresBootstrapStackVersion": 6,
105+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
106+
"additionalDependencies": [
107+
"StringSetAfterParallelDefaultTestDeployAssert649ABBB9.assets"
108+
],
109+
"lookupRole": {
110+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
111+
"requiresBootstrapStackVersion": 8,
112+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
113+
}
114+
},
115+
"dependencies": [
116+
"StringSetAfterParallelDefaultTestDeployAssert649ABBB9.assets"
117+
],
118+
"metadata": {
119+
"/StringSetAfterParallel/DefaultTest/DeployAssert/BootstrapVersion": [
120+
{
121+
"type": "aws:cdk:logicalId",
122+
"data": "BootstrapVersion"
123+
}
124+
],
125+
"/StringSetAfterParallel/DefaultTest/DeployAssert/CheckBootstrapVersion": [
126+
{
127+
"type": "aws:cdk:logicalId",
128+
"data": "CheckBootstrapVersion"
129+
}
130+
]
131+
},
132+
"displayName": "StringSetAfterParallel/DefaultTest/DeployAssert"
133+
}
134+
}
135+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "21.0.0",
3+
"files": {
4+
"30011aca79761d24d65d6f3f8af03bf4a54f58ac4a5fdbadcb2d1fb0fa225066": {
5+
"source": {
6+
"path": "stringset-after-parallel.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "30011aca79761d24d65d6f3f8af03bf4a54f58ac4a5fdbadcb2d1fb0fa225066.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)