Skip to content

Commit 029e0d2

Browse files
committed
test(stepfunctions): add integration test for JSONata TaskRole credentials
1 parent e411899 commit 029e0d2

File tree

9 files changed

+859
-569
lines changed

9 files changed

+859
-569
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/fake-task.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,33 @@ export class FakeTask extends sfn.TaskStateBase {
3535
};
3636
}
3737
}
38+
39+
/**
40+
* JSONata-compatible task for integ testing
41+
*/
42+
export class FakeTaskJsonata extends sfn.TaskStateBase {
43+
protected readonly taskMetrics?: sfn.TaskMetricsConfig;
44+
protected readonly taskPolicies?: iam.PolicyStatement[];
45+
protected readonly parameters?: { [key: string]: string };
46+
47+
constructor(scope: constructs.Construct, id: string, props: FakeTaskProps = {}) {
48+
super(scope, id, props);
49+
this.parameters = props.parameters;
50+
}
51+
52+
protected _renderTask(): any {
53+
return {
54+
Type: 'Task',
55+
Resource: 'arn:aws:states:::dynamodb:putItem',
56+
Arguments: {
57+
TableName: 'my-cool-table',
58+
Item: {
59+
id: {
60+
S: 'my-entry',
61+
},
62+
},
63+
...this.parameters,
64+
},
65+
};
66+
}
67+
}

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-credentials.js.snapshot/StateMachineCredentialsDefaultTestDeployAssert3F5E6D8D.assets.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-credentials.js.snapshot/aws-stepfunctions-state-machine-credentials-integ.assets.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-credentials.js.snapshot/aws-stepfunctions-state-machine-credentials-integ.template.json

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@
7878
"StateMachineWithLiteralCredentialsBF5A67AE": {
7979
"Type": "AWS::StepFunctions::StateMachine",
8080
"Properties": {
81-
"RoleArn": {
82-
"Fn::GetAtt": [
83-
"StateMachineWithLiteralCredentialsRole1F1DEEC1",
84-
"Arn"
85-
]
86-
},
8781
"DefinitionString": {
8882
"Fn::Join": [
8983
"",
@@ -98,6 +92,12 @@
9892
"\"},\"Resource\":\"arn:aws:states:::dynamodb:putItem\",\"Parameters\":{\"TableName\":\"my-cool-table\",\"Item\":{\"id\":{\"S\":\"my-entry\"}}}}},\"TimeoutSeconds\":30}"
9993
]
10094
]
95+
},
96+
"RoleArn": {
97+
"Fn::GetAtt": [
98+
"StateMachineWithLiteralCredentialsRole1F1DEEC1",
99+
"Arn"
100+
]
101101
}
102102
},
103103
"DependsOn": [
@@ -148,13 +148,13 @@
148148
"StateMachineWithCrossAccountLiteralCredentialsA2DD713D": {
149149
"Type": "AWS::StepFunctions::StateMachine",
150150
"Properties": {
151+
"DefinitionString": "{\"StartAt\":\"FakeTaskWithCrossAccountLiteralCredentials\",\"States\":{\"FakeTaskWithCrossAccountLiteralCredentials\":{\"End\":true,\"Type\":\"Task\",\"Credentials\":{\"RoleArn\":\"arn:aws:iam::123456789012:role/CrossAccountRole\"},\"Resource\":\"arn:aws:states:::dynamodb:putItem\",\"Parameters\":{\"TableName\":\"my-cool-table\",\"Item\":{\"id\":{\"S\":\"my-entry\"}}}}},\"TimeoutSeconds\":30}",
151152
"RoleArn": {
152153
"Fn::GetAtt": [
153154
"StateMachineWithCrossAccountLiteralCredentialsRole4AA04DBC",
154155
"Arn"
155156
]
156-
},
157-
"DefinitionString": "{\"StartAt\":\"FakeTaskWithCrossAccountLiteralCredentials\",\"States\":{\"FakeTaskWithCrossAccountLiteralCredentials\":{\"End\":true,\"Type\":\"Task\",\"Credentials\":{\"RoleArn\":\"arn:aws:iam::123456789012:role/CrossAccountRole\"},\"Resource\":\"arn:aws:states:::dynamodb:putItem\",\"Parameters\":{\"TableName\":\"my-cool-table\",\"Item\":{\"id\":{\"S\":\"my-entry\"}}}}},\"TimeoutSeconds\":30}"
157+
}
158158
},
159159
"DependsOn": [
160160
"StateMachineWithCrossAccountLiteralCredentialsRoleDefaultPolicy9B9943BD",
@@ -204,20 +204,76 @@
204204
"StateMachineWithJsonPathCredentials5786712E": {
205205
"Type": "AWS::StepFunctions::StateMachine",
206206
"Properties": {
207+
"DefinitionString": "{\"StartAt\":\"FakeTaskWithJsonPathCredentials\",\"States\":{\"FakeTaskWithJsonPathCredentials\":{\"End\":true,\"Type\":\"Task\",\"Credentials\":{\"RoleArn.$\":\"$.RoleArn\"},\"Resource\":\"arn:aws:states:::dynamodb:putItem\",\"Parameters\":{\"TableName\":\"my-cool-table\",\"Item\":{\"id\":{\"S\":\"my-entry\"}}}}},\"TimeoutSeconds\":30}",
207208
"RoleArn": {
208209
"Fn::GetAtt": [
209210
"StateMachineWithJsonPathCredentialsRole7BDE9FA6",
210211
"Arn"
211212
]
212-
},
213-
"DefinitionString": "{\"StartAt\":\"FakeTaskWithJsonPathCredentials\",\"States\":{\"FakeTaskWithJsonPathCredentials\":{\"End\":true,\"Type\":\"Task\",\"Credentials\":{\"RoleArn.$\":\"$.RoleArn\"},\"Resource\":\"arn:aws:states:::dynamodb:putItem\",\"Parameters\":{\"TableName\":\"my-cool-table\",\"Item\":{\"id\":{\"S\":\"my-entry\"}}}}},\"TimeoutSeconds\":30}"
213+
}
214214
},
215215
"DependsOn": [
216216
"StateMachineWithJsonPathCredentialsRoleDefaultPolicy1DA1C50B",
217217
"StateMachineWithJsonPathCredentialsRole7BDE9FA6"
218218
],
219219
"UpdateReplacePolicy": "Delete",
220220
"DeletionPolicy": "Delete"
221+
},
222+
"StateMachineWithJSONataCredentialsRole97AD3731": {
223+
"Type": "AWS::IAM::Role",
224+
"Properties": {
225+
"AssumeRolePolicyDocument": {
226+
"Statement": [
227+
{
228+
"Action": "sts:AssumeRole",
229+
"Effect": "Allow",
230+
"Principal": {
231+
"Service": "states.amazonaws.com"
232+
}
233+
}
234+
],
235+
"Version": "2012-10-17"
236+
}
237+
}
238+
},
239+
"StateMachineWithJSONataCredentialsRoleDefaultPolicyF552EED1": {
240+
"Type": "AWS::IAM::Policy",
241+
"Properties": {
242+
"PolicyDocument": {
243+
"Statement": [
244+
{
245+
"Action": "sts:AssumeRole",
246+
"Effect": "Allow",
247+
"Resource": "*"
248+
}
249+
],
250+
"Version": "2012-10-17"
251+
},
252+
"PolicyName": "StateMachineWithJSONataCredentialsRoleDefaultPolicyF552EED1",
253+
"Roles": [
254+
{
255+
"Ref": "StateMachineWithJSONataCredentialsRole97AD3731"
256+
}
257+
]
258+
}
259+
},
260+
"StateMachineWithJSONataCredentialsA18E2D6C": {
261+
"Type": "AWS::StepFunctions::StateMachine",
262+
"Properties": {
263+
"DefinitionString": "{\"StartAt\":\"FakeTaskWithJSONataCredentials\",\"States\":{\"FakeTaskWithJSONataCredentials\":{\"End\":true,\"Type\":\"Task\",\"Arguments\":{\"TableName\":\"my-cool-table\",\"Item\":{\"id\":{\"S\":\"my-entry\"}}},\"Credentials\":{\"RoleArn\":\"{% $states.input.RoleArn %}\"},\"Resource\":\"arn:aws:states:::dynamodb:putItem\"}},\"TimeoutSeconds\":30,\"QueryLanguage\":\"JSONata\"}",
264+
"RoleArn": {
265+
"Fn::GetAtt": [
266+
"StateMachineWithJSONataCredentialsRole97AD3731",
267+
"Arn"
268+
]
269+
}
270+
},
271+
"DependsOn": [
272+
"StateMachineWithJSONataCredentialsRoleDefaultPolicyF552EED1",
273+
"StateMachineWithJSONataCredentialsRole97AD3731"
274+
],
275+
"UpdateReplacePolicy": "Delete",
276+
"DeletionPolicy": "Delete"
221277
}
222278
},
223279
"Parameters": {

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-credentials.js.snapshot/cdk.out

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-credentials.js.snapshot/integ.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)