Giter Site home page Giter Site logo

ksomemo / aws-sfn-resume-from-any-state Goto Github PK

View Code? Open in Web Editor NEW

This project forked from awslabs/aws-sfn-resume-from-any-state

0.0 1.0 0.0 1.09 MB

Resume failed state machines midstream and skip all previously succeded steps.

License: Apache License 2.0

Python 100.00%

aws-sfn-resume-from-any-state's Introduction

aws-sfn-resume-from-any-state

Resume failed state machines midstream and skip all previously succeded steps.

This repository contains the CloudFormation template and code to support the Resume AWS Step Functions from Any State blog post.

The repository contains the following files:

  • "gotostate.py" - the script that creates a state machine that is able to resume execution of a failed state machine, from the point of failure.

  • "sample_execution_history" - an example execution history of a failed state machine, which the scipt parses in order to help resume workflows midstream.

  • "ResumeFromState.yaml" - a CloudFormation template that sets up a State Machine and Lambda functions to demonstrate this example.

Tutorial

The ResumeFromState.yaml CloudFormation template creates a State Machine and Lambda functions to illustrate how to use the 'gotostate.py' script in order to resume a state machine that has failed midstream.

To run this example, first use the CloudFormation template provided to create the sample State Machine and Lambda Functions.

In the AWS Step Function console, select the State Machine with "ResumeFromStateExample" in its title.

Run the state machine with the following input:

{
    "Message":"Your message here"
}

This input will cause the state machine to execute the first parallel state then fail, because the next step expects an input variable called "foo" in the JSON.

Let's use the 'gotostate.py' to resume this State Machine from the step it failed at - skipping states that had sucesfully been completed.

Run the script with the following command:

python gotostate.py --failedExecutionArn '<EXECUTION_ARN_OF_FAILED_STATE_MACHINE>'

This creates a new state machine with "-with-GoToState" appended to the title of the original state machine. The script also outputs the input that caused the state machine to fail with it was originally run.

Let's execute the new State Machine, adding the "foo" input variable that our workflow was expecting. We also need to set "resuming":true, so we can tell the new State Machine to branch to the failed state, and skip the states that had already succeeded.

{
  "foo": 1,
  "output": [
    {
      "Message": "Hello!"
    },
    {
      "Message": "Hello!"
    }
  ],
  "resuming": true
}

Run the new State Machine with the input above, and notice that it resumes from the failed states and completes execution sucessfully.

aws-sfn-resume-from-any-state's People

Contributors

hyandell avatar yash1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.