How to use the @aws-cdk/aws-stepfunctions.Choice function in @aws-cdk/aws-stepfunctions

To help you get started, we’ve selected a few @aws-cdk/aws-stepfunctions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fourTheorem / slic-starter / cicd / lib / stages / build-modules-stage.ts View on Github external
)

      const buildJob = new BuildJob(
        this,
        `${moduleName}_${stageName}_build_job`,
        {
          codeBuildProjectArn: this.buildModuleProjects[moduleName].projectArn,
          checkCodeBuildFunction: props.checkCodeBuildFunction,
          runCodeBuildFunction: props.runCodeBuildFunction,
          sourceLocationPath: '$.sourceLocation'
        }
      )

      // TODO - Fix this
      const changesPath = true || stageNo === 1 ? '$' : `$.[${moduleIndex}]`
      const ifChangedChoice = new Choice(
        this,
        `${moduleName} changed? ${stageName} build`
      )
        .when(
          Condition.or(
            Condition.booleanEquals(
              `${changesPath}.changes.${moduleName}`,
              true
            ),
            Condition.booleanEquals(`${changesPath}.changes.all_modules`, true)
          ),
          buildJob.task
        )
        .otherwise(new Succeed(this, `Skip ${stageName} ${moduleName} build`))

      this.stageState.branch(ifChangedChoice)
github fourTheorem / slic-starter / cicd / lib / stages / build-job.ts View on Github external
parameters: {
        'build.$': `$.runBuildResult.${id}.build`
      },
      inputPath: `$`,
      resultPath: `$.buildStatus.${id}`,
      outputPath: '$'
    })

    const waitForBuild = new Wait(this, `Wait for ${id}`, {
      duration: WaitDuration.seconds(10)
    })

    this.task.next(waitForBuild)
    waitForBuild.next(checkBuildTask)
    checkBuildTask.next(
      new Choice(this, `${id} done?`)
        .when(
          Condition.stringEquals(
            `$.buildStatus.${id}.buildStatus`,
            'SUCCEEDED'
          ),
          new Succeed(this, `Success ${id}`)
        )
        .when(
          Condition.stringEquals(
            `$.buildStatus.${id}.buildStatus`,
            'IN_PROGRESS'
          ),
          waitForBuild
        )
        .otherwise(new Fail(this, `Failure ${id}`))
    )
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
});
  const invokeDispatcher = new tasks.LambdaInvoke(
    scope,
    "InvokeDispatchInspection",
    { lambdaFunction: dispatchInspection }
  );
  const invokeErrorHandler = new tasks.LambdaInvoke(
    scope,
    "InvokeErrorHandler",
    { lambdaFunction: errorHandler }
  );

  const definition = wait
    .next(invokeDispatcher)
    .next(
      new sfn.Choice(scope, "Job Complete?").when(
        sfn.Condition.stringEquals("$.status", "FAILED"),
        invokeErrorHandler
      )
    );

  return new sfn.StateMachine(scope, "InspectionMachine", {
    definition,
    role: sfnRole,
  });
}
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
lambdaFunction: compileReport,
          })
        )
    )
    .next(
      new sfn.Choice(scope, "Job Complete?")
        .when(condFailed, invokeErrorHandler)
        .when(
          sfn.Condition.stringEquals("$.status", "SUCCEEDED"),
          new tasks.LambdaInvoke(scope, "invokeReviewer", {
            lambdaFunction: reviewer,
          })
        )
    )
    .next(
      new sfn.Choice(scope, "Job Complete?")
        .when(condFailed, invokeErrorHandler)
        .when(
          sfn.Condition.stringEquals("$.status", "SUCCEEDED"),
          new tasks.LambdaInvoke(scope, "invokePublishReport", {
            lambdaFunction: publishReport,
          })
        )
    );

  return new sfn.StateMachine(scope, "InspectionMachine", {
    definition,
    role: sfnRole,
  });
}
github fourTheorem / slic-starter / cicd / lib / stages / deploy-modules-stage.ts View on Github external
role: props.codeBuildRole
        }
      )

      const deployJob = new BuildJob(
        this,
        `${moduleName}_${stageName}_deploy_job`,
        {
          codeBuildProjectArn: this.deployModuleProjects[moduleName].projectArn,
          checkCodeBuildFunction: props.checkCodeBuildFunction,
          runCodeBuildFunction: props.runCodeBuildFunction,
          sourceLocationPath: `$.[${moduleIndex}].runBuildResult.${moduleName}_${stageName}_build_job`
        }
      )

      const ifChangedChoice = new Choice(
        this,
        `${moduleName} changed? ${stageName} deploy`
      )
        .when(
          Condition.booleanEquals(
            `$.[${moduleIndex}].changes.${moduleName}`,
            true
          ),
          deployJob.task
        )
        .otherwise(new Succeed(this, `Skip ${stageName} ${moduleName} deploy`))

      this.stageState.branch(ifChangedChoice)
    })
  }