Skip to content

Commit d19e538

Browse files
authored
fix(stepfunctions-tasks): EMR Create Cluster does not support dynamic allocation of step concurrency level (#18972)
Currently, it is not possible to set the `stepConcurrencyLevel` property dynamically as the validation in place will step over it and indicate that the value specified at a JsonPath is invalid. This fix adds a check to skip validation if the property contains an unresolved token ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d8bc0d0 commit d19e538

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/@aws-cdk/aws-stepfunctions-tasks/lib/emr/emr-create-cluster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class EmrCreateCluster extends sfn.TaskStateBase {
206206
this.validateReleaseLabel(this.props.releaseLabel);
207207
}
208208

209-
if (this.props.stepConcurrencyLevel !== undefined) {
209+
if (this.props.stepConcurrencyLevel !== undefined && !cdk.Token.isUnresolved(this.props.stepConcurrencyLevel)) {
210210
if (this.props.stepConcurrencyLevel < 1 || this.props.stepConcurrencyLevel > 256) {
211211
throw new Error(`Step concurrency level must be in range [1, 256], but got ${this.props.stepConcurrencyLevel}.`);
212212
}

packages/@aws-cdk/aws-stepfunctions-tasks/test/emr/emr-create-cluster.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ describe('Cluster with StepConcurrencyLevel', () => {
202202
});
203203
});
204204

205+
test('can be set dynamically through JsonPath', async () => {
206+
// WHEN
207+
const task = new EmrCreateCluster(stack, 'Task', {
208+
instances: {},
209+
clusterRole,
210+
name: 'Cluster',
211+
serviceRole,
212+
autoScalingRole,
213+
stepConcurrencyLevel: sfn.JsonPath.numberAt('$.foo.bar'),
214+
integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE,
215+
});
216+
217+
// THEN
218+
expect(stack.resolve(task.toStateJson())).toMatchObject({
219+
Parameters: {
220+
'Name': 'Cluster',
221+
'StepConcurrencyLevel.$': '$.foo.bar',
222+
},
223+
});
224+
});
225+
205226
test('throws if < 1 or > 256', async () => {
206227
expect(() => new EmrCreateCluster(stack, 'Task1', {
207228
instances: {},

0 commit comments

Comments
 (0)