How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import * as lambda from '@aws-cdk/aws-lambda';
    
    declare const submitLambda: lambda.Function;
    declare const getStatusLambda: lambda.Function;
    
    const submitJob = new tasks.LambdaInvoke(this, 'Submit Job', {
      lambdaFunction: submitLambda,
      // Lambda's result is in the attribute `Payload`
      outputPath: '$.Payload',
    });
    
    const waitX = new sfn.Wait(this, 'Wait X Seconds', {
      time: sfn.WaitTime.secondsPath('$.waitSeconds'),
    });
    
    const getStatus = new tasks.LambdaInvoke(this, 'Get Job Status', {
      lambdaFunction: getStatusLambda,
      // Pass just the field named "guid" into the Lambda, put the
      // Lambda's result in a field called "status" in the response
      inputPath: '$.guid',
      outputPath: '$.Payload',
    });
    
    const jobFailed = new sfn.Fail(this, 'Job Failed', {
      cause: 'AWS Batch Job Failed',
      error: 'DescribeJob returned FAILED',
    });
    
    const finalStatus = new tasks.LambdaInvoke(this, 'Get Final Job Status', {
      lambdaFunction: getStatusLambda,
      // Use "guid" field as input
      inputPath: '$.guid',
      outputPath: '$.Payload',
    });
    
    const definition = submitJob
      .next(waitX)
      .next(getStatus)
      .next(new sfn.Choice(this, 'Job Complete?')
        // Look at the "status" field
        .when(sfn.Condition.stringEquals('$.status', 'FAILED'), jobFailed)
        .when(sfn.Condition.stringEquals('$.status', 'SUCCEEDED'), finalStatus)
        .otherwise(waitX));
    
    new sfn.StateMachine(this, 'StateMachine', {
      definition,
      timeout: Duration.minutes(5),
    });
    
    Docs
    0
  • // The code below shows an example of how to instantiate this type.
    // The values are placeholders you should change.
    import * as stepfunctions from '@aws-cdk/aws-stepfunctions';
    
    const errors = new stepfunctions.Errors();
    
    Docs
    0
  • const map = new sfn.Map(this, 'Map State', {
      maxConcurrency: 1,
      itemsPath: sfn.JsonPath.stringAt('$.inputForMap'),
    });
    map.iterator(new sfn.Pass(this, 'Pass State'));
    
    Docs
    0
  • // Makes the current JSON state { ..., "subObject": { "hello": "world" } }
    const pass = new sfn.Pass(this, 'Add Hello World', {
      result: sfn.Result.fromObject({ hello: 'world' }),
      resultPath: '$.subObject',
    });
    
    // Set the next state
    const nextState = new sfn.Pass(this, 'NextState');
    pass.next(nextState);
    
    Docs
    0
  • new sfn.StateMachine(this, 'MyStateMachine', {
      definition: sfn.Chain.start(new sfn.Pass(this, 'Pass')),
      tracingEnabled: true,
    });
    
    Docs
    0
  • import * as logs from '@aws-cdk/aws-logs';
    
    const logGroup = new logs.LogGroup(this, 'MyLogGroup');
    
    new sfn.StateMachine(this, 'MyStateMachine', {
      definition: sfn.Chain.start(new sfn.Pass(this, 'Pass')),
      logs: {
        destination: logGroup,
        level: sfn.LogLevel.ALL,
      },
    });
    
    Docs
    0
  • const map = new sfn.Map(this, 'Map State', {
      maxConcurrency: 1,
      itemsPath: sfn.JsonPath.stringAt('$.inputForMap'),
    });
    map.iterator(new sfn.Pass(this, 'Pass State'));
    
    Docs
    0
  • // Define a state machine with one Pass state
    const child = new sfn.StateMachine(this, 'ChildStateMachine', {
      definition: sfn.Chain.start(new sfn.Pass(this, 'PassState')),
    });
    
    // Include the state machine in a Task state with callback pattern
    const task = new tasks.StepFunctionsStartExecution(this, 'ChildTask', {
      stateMachine: child,
      integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
      input: sfn.TaskInput.fromObject({
        token: sfn.JsonPath.taskToken,
        foo: 'bar',
      }),
      name: 'MyExecutionName',
    });
    
    // Define a second state machine with the Task state above
    new sfn.StateMachine(this, 'ParentStateMachine', {
      definition: task,
    });
    
    Docs
    0
  • // Makes the current JSON state { ..., "subObject": { "hello": "world" } }
    const pass = new sfn.Pass(this, 'Add Hello World', {
      result: sfn.Result.fromObject({ hello: 'world' }),
      resultPath: '$.subObject',
    });
    
    // Set the next state
    const nextState = new sfn.Pass(this, 'NextState');
    pass.next(nextState);
    
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples