Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(stepfunctions-tasks): default to NODEJS_14_X for EvaluateExpression #13267

Merged
merged 4 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/@aws-cdk/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const convertToSeconds = new tasks.EvaluateExpression(this, 'Convert to seconds'
const createMessage = new tasks.EvaluateExpression(this, 'Create message', {
// Note: this is a string inside a string.
expression: '`Now waiting ${$.waitSeconds} seconds...`',
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
resultPath: '$.message',
});

Expand All @@ -212,9 +212,8 @@ new sfn.StateMachine(this, 'StateMachine', {
```

The `EvaluateExpression` supports a `runtime` prop to specify the Lambda
runtime to use to evaluate the expression. Currently, the only runtime
supported is `lambda.Runtime.NODEJS_10_X`.

runtime to use to evaluate the expression. Currently, only runtimes
of the Node.js family are supported.

## Athena

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface EvaluateExpressionProps extends sfn.TaskStateBaseProps {
/**
* The runtime language to use to evaluate the expression.
*
* @default lambda.Runtime.NODEJS_10_X
* @default lambda.Runtime.NODEJS_14_X
*/
readonly runtime?: lambda.Runtime;
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export class EvaluateExpression extends sfn.TaskStateBase {
constructor(scope: Construct, id: string, private readonly props: EvaluateExpressionProps) {
super(scope, id, props);

this.evalFn = createEvalFn(this.props.runtime || lambda.Runtime.NODEJS_10_X, this);
this.evalFn = createEvalFn(this.props.runtime ?? lambda.Runtime.NODEJS_14_X, this);

this.taskPolicies = [
new iam.PolicyStatement({
Expand Down Expand Up @@ -97,17 +97,18 @@ export class EvaluateExpression extends sfn.TaskStateBase {
}

function createEvalFn(runtime: lambda.Runtime, scope: Construct) {
const code = lambda.Code.asset(path.join(__dirname, `eval-${runtime.name}-handler`));
const lambdaPurpose = 'Eval';

switch (runtime) {
case lambda.Runtime.NODEJS_14_X:
case lambda.Runtime.NODEJS_12_X:
case lambda.Runtime.NODEJS_10_X:
return new lambda.SingletonFunction(scope, 'EvalFunction', {
runtime,
handler: 'index.handler',
uuid: 'a0d2ce44-871b-4e74-87a1-f5e63d7c3bdc',
lambdaPurpose,
code,
code: lambda.Code.fromAsset(path.join(__dirname, 'eval-nodejs-handler')),
});
// TODO: implement other runtimes
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Event } from '../lib';
import { handler } from '../lib/eval-nodejs10.x-handler';
import { handler } from '../lib/eval-nodejs-handler';

test('with numbers', async () => {
// GIVEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('Eval with Node.js', () => {
});

expect(stack).toHaveResource('AWS::Lambda::Function', {
Runtime: 'nodejs10.x',
Runtime: 'nodejs14.x',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParameters640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0S3BucketA16CB30E"
"Ref": "AssetParametersbc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626bS3Bucket743A2950"
},
"S3Key": {
"Fn::Join": [
Expand All @@ -49,7 +49,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0S3VersionKey102DBBD9"
"Ref": "AssetParametersbc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626bS3VersionKey2DBCB833"
}
]
}
Expand All @@ -62,7 +62,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0S3VersionKey102DBBD9"
"Ref": "AssetParametersbc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626bS3VersionKey2DBCB833"
}
]
}
Expand All @@ -72,14 +72,14 @@
]
}
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"Evala0d2ce44871b4e7487a1f5e63d7c3bdcServiceRoleDC85DDD3",
"Arn"
]
},
"Runtime": "nodejs10.x"
"Handler": "index.handler",
"Runtime": "nodejs14.x"
},
"DependsOn": [
"Evala0d2ce44871b4e7487a1f5e63d7c3bdcServiceRoleDC85DDD3"
Expand Down Expand Up @@ -185,17 +185,17 @@
}
},
"Parameters": {
"AssetParameters640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0S3BucketA16CB30E": {
"AssetParametersbc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626bS3Bucket743A2950": {
"Type": "String",
"Description": "S3 bucket for asset \"640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0\""
"Description": "S3 bucket for asset \"bc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626b\""
},
"AssetParameters640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0S3VersionKey102DBBD9": {
"AssetParametersbc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626bS3VersionKey2DBCB833": {
"Type": "String",
"Description": "S3 key for asset version \"640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0\""
"Description": "S3 key for asset version \"bc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626b\""
},
"AssetParameters640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0ArtifactHash43D553D7": {
"AssetParametersbc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626bArtifactHashAD6C554B": {
"Type": "String",
"Description": "Artifact hash for asset \"640b7d3e1a6ff78c1cad25c2d7396d04c74d6eee31b116f4c86d910338d480d0\""
"Description": "Artifact hash for asset \"bc320c7bd6a0eba90db647aa586cf65548560a54c141153fdc12f22eb3b2626b\""
}
},
"Outputs": {
Expand All @@ -205,4 +205,4 @@
}
}
}
}
}