in source/src/molecule-unfolding/cdk/construct-benchmark.ts [329:399]
private createRunOnQCDeviceStateMachine(): sfn.StateMachine {
const checkQCDeviceLambda = this.lambdaUtil.createCheckQCDeviceLambda()
const checkQCDeviceStep = new tasks.LambdaInvoke(this, "Check Device status", {
lambdaFunction: checkQCDeviceLambda,
payload: sfn.TaskInput.fromObject({
"execution_id": sfn.JsonPath.stringAt("$.execution_id"),
"device_arn": sfn.JsonPath.stringAt("$.device_arn")
}),
resultSelector: {
"statusPayload": sfn.JsonPath.stringAt('$.Payload'),
},
resultPath: sfn.JsonPath.stringAt('$.checkQCDeviceStep')
});
const getParametersLambdaStep = new tasks.LambdaInvoke(this, 'Get Task Paramters', {
lambdaFunction: this.taskParamLambda,
payload: sfn.TaskInput.fromObject({
"s3_bucket": this.props.bucket.bucketName,
"s3_prefix": this.props.prefix,
"param_type": "PARAMS_FOR_QC_DEVICE",
"device_arn.$": "$.device_arn",
"execution_id": sfn.JsonPath.stringAt("$.execution_id")
}),
outputPath: '$.Payload'
});
const submitQCTaskStep = this.submitQCTaskAndWaitForTokenStep();
const parallelQCJobsMap = new sfn.Map(this, 'ParallelQCJobs', {
maxConcurrency: 20,
itemsPath: sfn.JsonPath.stringAt('$.qcTaskParams'),
parameters: {
"ItemIndex.$": "$$.Map.Item.Index",
"ItemValue.$": "$$.Map.Item.Value",
"execution_id.$": "$.execution_id"
},
resultPath: "$.parallelQCJobsMap"
});
parallelQCJobsMap.iterator(submitQCTaskStep);
const deviceOfflineFail = new sfn.Fail(this, "Device Not Online")
const choiceStep = new sfn.Choice(this, "Device Online ?")
.when(sfn.Condition.stringEquals("$.checkQCDeviceStep.statusPayload.deviceStatus", 'ONLINE'),
getParametersLambdaStep.next(parallelQCJobsMap))
.otherwise(deviceOfflineFail)
const chain = sfn.Chain.start(checkQCDeviceStep).next(choiceStep);
const logGroupName = `${this.props.stackName}-QCDeviceStateMachineLogGroup`
grantKmsKeyPerm(this.logKey, logGroupName)
const logGroup = new logs.LogGroup(this, 'QCDeviceStateMachineLogGroup', {
encryptionKey: this.logKey,
logGroupName,
removalPolicy: cdk.RemovalPolicy.DESTROY,
retention: logs.RetentionDays.THREE_MONTHS
});
const qcDeviceStateMachine = new sfn.StateMachine(this, 'QCDeviceStateMachine', {
definition: chain,
logs: {
destination: logGroup,
level: sfn.LogLevel.ALL,
},
});
logGroup.grantWrite(qcDeviceStateMachine)
return qcDeviceStateMachine;
}