Skip to content

Commit dfea721

Browse files
authored
fix(stepfunctions-tasks): runtime language used to evaluate expressions is ignored (#30302)
### Reason for this change `EvaluateExpression` exposes a runtime property that can be used to configure the runtime language used to evaluate an expression. When the handler for this was migrated into the handler framework we hid the runtime property and didn't make it configurable. As a result, when the runtime property is specified as part of `EvaluateExpressionProps` it ends up being dropped in place of the code generated runtime. ### Description of changes Added a configurable runtime property to the generated `EvalNodejsSingletonFunctionProps` interface and set this property using runtime property on `EvaluateExpressionProps` if one was provided. Otherwise, the current node 18 default is used. ### Description of how you validated changes Unit test for codegen with eval-nodejs-provider. Integ test for default `EvaluateExpression` runtime (we already test a configurable runtime, unfortunately this was the same as the default so this bug was not caught). ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a2e8dc5 commit dfea721

File tree

15 files changed

+1045
-2
lines changed

15 files changed

+1045
-2
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/integ.evaluate-expression-default-runtime.js.snapshot/EvaluateExpressionIntegDefaultTestDeployAssert03097648.assets.json

Lines changed: 19 additions & 0 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-tasks/test/integ.evaluate-expression-default-runtime.js.snapshot/EvaluateExpressionIntegDefaultTestDeployAssert03097648.template.json

Lines changed: 36 additions & 0 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-tasks/test/integ.evaluate-expression-default-runtime.js.snapshot/asset.b8cec122f25692e8b194663d25a2ee5e0b65e55df966120791d6a3ddc08fc136/index.js

Lines changed: 1 addition & 0 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-tasks/test/integ.evaluate-expression-default-runtime.js.snapshot/cdk-sfn-evaluate-expression-default-runtime-integ.assets.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
{
2+
"Resources": {
3+
"Eval41256dc5445742738ed917bc818694e5ServiceRoleA1AB6027": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"Eval41256dc5445742738ed917bc818694e54EB1134F": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Code": {
38+
"S3Bucket": {
39+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
40+
},
41+
"S3Key": "b8cec122f25692e8b194663d25a2ee5e0b65e55df966120791d6a3ddc08fc136.zip"
42+
},
43+
"Handler": "index.handler",
44+
"Role": {
45+
"Fn::GetAtt": [
46+
"Eval41256dc5445742738ed917bc818694e5ServiceRoleA1AB6027",
47+
"Arn"
48+
]
49+
},
50+
"Runtime": "nodejs18.x"
51+
},
52+
"DependsOn": [
53+
"Eval41256dc5445742738ed917bc818694e5ServiceRoleA1AB6027"
54+
]
55+
},
56+
"StateMachineRoleB840431D": {
57+
"Type": "AWS::IAM::Role",
58+
"Properties": {
59+
"AssumeRolePolicyDocument": {
60+
"Statement": [
61+
{
62+
"Action": "sts:AssumeRole",
63+
"Effect": "Allow",
64+
"Principal": {
65+
"Service": "states.amazonaws.com"
66+
}
67+
}
68+
],
69+
"Version": "2012-10-17"
70+
}
71+
}
72+
},
73+
"StateMachineRoleDefaultPolicyDF1E6607": {
74+
"Type": "AWS::IAM::Policy",
75+
"Properties": {
76+
"PolicyDocument": {
77+
"Statement": [
78+
{
79+
"Action": "lambda:InvokeFunction",
80+
"Effect": "Allow",
81+
"Resource": [
82+
{
83+
"Fn::GetAtt": [
84+
"Eval41256dc5445742738ed917bc818694e54EB1134F",
85+
"Arn"
86+
]
87+
},
88+
{
89+
"Fn::Join": [
90+
"",
91+
[
92+
{
93+
"Fn::GetAtt": [
94+
"Eval41256dc5445742738ed917bc818694e54EB1134F",
95+
"Arn"
96+
]
97+
},
98+
":*"
99+
]
100+
]
101+
}
102+
]
103+
}
104+
],
105+
"Version": "2012-10-17"
106+
},
107+
"PolicyName": "StateMachineRoleDefaultPolicyDF1E6607",
108+
"Roles": [
109+
{
110+
"Ref": "StateMachineRoleB840431D"
111+
}
112+
]
113+
}
114+
},
115+
"StateMachine2E01A3A5": {
116+
"Type": "AWS::StepFunctions::StateMachine",
117+
"Properties": {
118+
"DefinitionString": {
119+
"Fn::Join": [
120+
"",
121+
[
122+
"{\"StartAt\":\"Sum\",\"States\":{\"Sum\":{\"Next\":\"Multiply\",\"Type\":\"Task\",\"ResultPath\":\"$.c\",\"Resource\":\"",
123+
{
124+
"Fn::GetAtt": [
125+
"Eval41256dc5445742738ed917bc818694e54EB1134F",
126+
"Arn"
127+
]
128+
},
129+
"\",\"Parameters\":{\"expression\":\"$.a + $.b\",\"expressionAttributeValues\":{\"$.a.$\":\"$.a\",\"$.b.$\":\"$.b\"}}},\"Multiply\":{\"Next\":\"Wait\",\"Type\":\"Task\",\"ResultPath\":\"$.d\",\"Resource\":\"",
130+
{
131+
"Fn::GetAtt": [
132+
"Eval41256dc5445742738ed917bc818694e54EB1134F",
133+
"Arn"
134+
]
135+
},
136+
"\",\"Parameters\":{\"expression\":\"$.c * 2\",\"expressionAttributeValues\":{\"$.c.$\":\"$.c\"}}},\"Wait\":{\"Type\":\"Wait\",\"SecondsPath\":\"$.d\",\"Next\":\"Now\"},\"Now\":{\"End\":true,\"Type\":\"Task\",\"ResultPath\":\"$.now\",\"Resource\":\"",
137+
{
138+
"Fn::GetAtt": [
139+
"Eval41256dc5445742738ed917bc818694e54EB1134F",
140+
"Arn"
141+
]
142+
},
143+
"\",\"Parameters\":{\"expression\":\"(new Date()).toUTCString()\",\"expressionAttributeValues\":{}}}}}"
144+
]
145+
]
146+
},
147+
"RoleArn": {
148+
"Fn::GetAtt": [
149+
"StateMachineRoleB840431D",
150+
"Arn"
151+
]
152+
}
153+
},
154+
"DependsOn": [
155+
"StateMachineRoleDefaultPolicyDF1E6607",
156+
"StateMachineRoleB840431D"
157+
],
158+
"UpdateReplacePolicy": "Delete",
159+
"DeletionPolicy": "Delete"
160+
}
161+
},
162+
"Outputs": {
163+
"StateMachineARN": {
164+
"Value": {
165+
"Ref": "StateMachine2E01A3A5"
166+
}
167+
}
168+
},
169+
"Parameters": {
170+
"BootstrapVersion": {
171+
"Type": "AWS::SSM::Parameter::Value<String>",
172+
"Default": "/cdk-bootstrap/hnb659fds/version",
173+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
174+
}
175+
},
176+
"Rules": {
177+
"CheckBootstrapVersion": {
178+
"Assertions": [
179+
{
180+
"Assert": {
181+
"Fn::Not": [
182+
{
183+
"Fn::Contains": [
184+
[
185+
"1",
186+
"2",
187+
"3",
188+
"4",
189+
"5"
190+
],
191+
{
192+
"Ref": "BootstrapVersion"
193+
}
194+
]
195+
}
196+
]
197+
},
198+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
199+
}
200+
]
201+
}
202+
}
203+
}

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/integ.evaluate-expression-default-runtime.js.snapshot/cdk.out

Lines changed: 1 addition & 0 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-tasks/test/integ.evaluate-expression-default-runtime.js.snapshot/integ.json

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

0 commit comments

Comments
 (0)