private createQCStateMachine()

in source/src/molecule-unfolding/cdk/construct-benchmark.ts [269:327]


    private createQCStateMachine(): sfn.StateMachine {

        const getDeviceListLambdaStep = new tasks.LambdaInvoke(this, 'Get Device List', {
            lambdaFunction: this.taskParamLambda,
            payload: sfn.TaskInput.fromObject({
                "s3_bucket": this.props.bucket.bucketName,
                "s3_prefix": this.props.prefix,
                "param_type": "QC_DEVICE_LIST",
                "execution_id": sfn.JsonPath.stringAt("$.execution_id"),
                "context.$": "$$"
            }),
            outputPath: '$.Payload'
        });

        const runOnQCDeviceStateMachine = this.createRunOnQCDeviceStateMachine()

        const runOnQCDeviceStateMachineStep = new tasks.StepFunctionsStartExecution(this, "Run On Device", {
            stateMachine: runOnQCDeviceStateMachine,
            integrationPattern: sfn.IntegrationPattern.RUN_JOB,
            associateWithParent: true,
            input: sfn.TaskInput.fromObject({
                "device_arn": sfn.JsonPath.stringAt("$.ItemValue"),
                "execution_id": sfn.JsonPath.stringAt("$.execution_id")
            })
        });

        const parallelQCDeviceMap = new sfn.Map(this, 'parallelQCDeviceMap', {
            maxConcurrency: 20,
            itemsPath: sfn.JsonPath.stringAt('$.devices_arns'),
            parameters: {
                "ItemIndex.$": "$$.Map.Item.Index",
                "ItemValue.$": "$$.Map.Item.Value",
                "execution_id.$": "$.execution_id"
            },
            resultPath: "$.parallelQCDeviceMap"
        });
        parallelQCDeviceMap.iterator(runOnQCDeviceStateMachineStep);

        const logGroupName = `${this.props.stackName}-QCStateMachineLogGroup`
        grantKmsKeyPerm(this.logKey, logGroupName)

        const logGroup = new logs.LogGroup(this, 'QCStateMachineLogGroup', {
            encryptionKey: this.logKey,
            logGroupName,
            removalPolicy: cdk.RemovalPolicy.DESTROY,
            retention: logs.RetentionDays.THREE_MONTHS
        });

        const qcStateMachine = new sfn.StateMachine(this, 'QCStateMachine', {
            definition: getDeviceListLambdaStep.next(parallelQCDeviceMap),
            logs: {
                destination: logGroup,
                level: sfn.LogLevel.ALL,
            },
        });
        logGroup.grantWrite(qcStateMachine)

        return qcStateMachine;
    }