How to use @aws-cdk/aws-stepfunctions-tasks - 8 common examples

To help you get started, we’ve selected a few @aws-cdk/aws-stepfunctions-tasks 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 deepalert / deepalert / lib / deepalert-stack.ts View on Github external
function buildInspectionMachine(
  scope: cdk.Construct,
  dispatchInspection: lambda.Function,
  errorHandler: lambda.Function,
  delay?: cdk.Duration,
  sfnRole?: iam.IRole
): sfn.StateMachine {
  const waitTime = delay || cdk.Duration.minutes(5);

  const wait = new sfn.Wait(scope, "WaitDispatch", {
    time: sfn.WaitTime.duration(waitTime),
  });
  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
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
function buildReviewMachine(
  scope: cdk.Construct,
  compileReport: lambda.Function,
  reviewer: lambda.Function,
  publishReport: lambda.Function,
  errorHandler: lambda.Function,
  delay?: cdk.Duration,
  sfnRole?: iam.IRole
): sfn.StateMachine {
  const waitTime = delay || cdk.Duration.minutes(10);

  const invokeErrorHandler = new tasks.LambdaInvoke(
    scope,
    "InvokeErrorHandler",
    { lambdaFunction: errorHandler }
  );
  const condFailed = sfn.Condition.stringEquals("$.status", "FAILED");
  const condSucceeded = sfn.Condition.stringEquals("$.status", "SUCCEEDED");

  const wait = new sfn.Wait(scope, "WaitCompile", {
    time: sfn.WaitTime.duration(waitTime),
  });

  const definition = wait
    .next(
      new sfn.Choice(scope, "Job Complete?")
        .when(condFailed, invokeErrorHandler)
        .when(
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
dispatchInspection: lambda.Function,
  errorHandler: lambda.Function,
  delay?: cdk.Duration,
  sfnRole?: iam.IRole
): sfn.StateMachine {
  const waitTime = delay || cdk.Duration.minutes(5);

  const wait = new sfn.Wait(scope, "WaitDispatch", {
    time: sfn.WaitTime.duration(waitTime),
  });
  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,
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
{ lambdaFunction: errorHandler }
  );
  const condFailed = sfn.Condition.stringEquals("$.status", "FAILED");
  const condSucceeded = sfn.Condition.stringEquals("$.status", "SUCCEEDED");

  const wait = new sfn.Wait(scope, "WaitCompile", {
    time: sfn.WaitTime.duration(waitTime),
  });

  const definition = wait
    .next(
      new sfn.Choice(scope, "Job Complete?")
        .when(condFailed, invokeErrorHandler)
        .when(
          condSucceeded,
          new tasks.LambdaInvoke(scope, "invokeCompileReport", {
            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?")
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
.next(
      new sfn.Choice(scope, "Job Complete?")
        .when(condFailed, invokeErrorHandler)
        .when(
          condSucceeded,
          new tasks.LambdaInvoke(scope, "invokeCompileReport", {
            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", {
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
.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 aws / aws-cdk / packages / @aws-cdk / custom-resources / lib / provider-framework / provider.ts View on Github external
private createTask(handler: lambda.Function) {
    return new sfn.Task(this, `${handler.node.id}-task`, {
      task: new tasks.InvokeFunction(handler),
    });
  }
}
github guardian / editions / projects / aws / lib / constructs.ts View on Github external
export const task = (
    scope: cdk.Construct,
    name: string,
    desc: string,
    { retry, ...lambdaParams }: Params,
    environment?: { [key: string]: string },
    overrides?: Partial,
) => {
    const lambda = taskLambda(scope, name, lambdaParams, environment, overrides)

    const task = new sfn.Task(scope, [name, desc].join(': '), {
        task: new tasks.InvokeFunction(lambda),
    })
    if (retry == true) {
        task.addRetry(retry === true ? {} : retry)
    }
    return { lambda, task }
}

@aws-cdk/aws-stepfunctions-tasks

Task integrations for AWS StepFunctions

Apache-2.0
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis