Introducing AWS Step Functions
- Step Functions is a serverless orchestration service that lets you combine AWS Lambda functions and other AWS services to build business-critical applications.
- Through Step Functions graphical console, you see your application’s workflow as a series of event-driven steps.
- AWS Step Functions is a web service that enables you to coordinate the components of distributed applications and microservices using visual workflows.
- Step Functions manage the operations and underlying infrastructure for you to ensure your application is available at any scale.
- Building applications from individual components that each perform a discrete function lets you scale and change applications quickly. Step Functions is a reliable way to coordinate components and step through the functions of your application.
- With AWS Step Functions you pay only for the transition from one step of your application workflow to the next, referred to as a state transition. Billing is metered by state transition, regardless of how long each state persists (up to one year). The AWS Step Functions free tier includes 4,000 state transitions each month.
Before you get started with AWS Step Functions for the first time, complete the prerequisites that are listed below.
- Create an AWS account
- Create an IAM user and group
- Create an access key for your IAM user
Getting started with AWS Step Functions
In this blog, you learn the basics of working with Step Functions. You sign in to the Step Functions console, where you create a state machine that uses two “Pass” states. You then start a new execution and review the execution details. You then change one of the “Pass” state’s results and view the changes. Finally, you perform a clean-up step, where you delete your state machine. At the end of this tutorial, you'll know how to create, test, debug, and delete a state machine.
- Create a state machine
- Start an new execution
- Update a state machine
- Delete a state machine
Step 1: Create a state machine
A state machine is a graphical representation of your workflow that you can use to examine the individual steps that define it.
To create a state machine from a predefined Hello world template
- Sign in to the Step Functions console.
- On the Define a state machine page, choose Start with a template, and then choose Hello world.
- Under Type, choose Standard.
- Under Definition, review the state machine's workflow.
The state machine has two panes: a code pane and a visual workflow pane. The code pane is where you define the workflow for your application. The visual workflow pane is where Step Functions shows a graph of your workflow as a series of steps.
If the graph doesn't appear in the visual workflow pane, choose the refresh icon in the top left corner.
- Choose Next.
- Under Permissions, select Create a new IAM role.
When you create a state machine, you select an IAM role that defines which resources the state machine has permission to access during its execution. Choose from the following options:
- Create a new IAM role – Select this option when you want Step Functions to create a new IAM role for you based on the definition of your state machine and its configuration details.
- Choose an existing role – Select this option if you previously created an IAM role for Step Functions and your state machine has the correct permissions.
- Enter a role ARN – Select this option if you know the ARN details for the IAM role that you want to use for Step Functions.
- Choose Create state machine.
Step 2: Start an new execution
To start a new execution
- On the Helloworld page, choose Start execution.
- Optional - On the New execution page, in the exection ID field, you can enter a name of your choice.
Make sure that the execution name doesn’t contain any non-ASCII characters. If you don’t specify your own execution ID, Step Functions generates a unique execution ID for you.
- On the New execution page, choose Start execution.
After you choose Start execution, the Step Functions console directs you to a page that's titled with your execution ID. On this page, you can review the results of your new execution. Under Execution details, you can see your execution ARN and a status to indicate whether your execution succeeded. You can also see the timestamps for when your execution started and ended.
- To view the results of your execution, choose Output.
The output is World.
Step 3: Update a state machine
Change a Pass state's result, and update your state machine for future exceptions. Then view your changes in the visual workflow pane. An exception is an event that disrupts a step in your workflow.
To change a Pass state's result
- On the page titled with your execution ID, choose Edit state machine.
- On the Edit Helloworld page, in the code pane, update the second Result to World has been updated!
- Choose Save, and then choose Start execution.
After you choose Save, the following message appears:
"The changes to your state machine may affect which resources it needs to access. To ensure your state machine has the right permissions, you might need to edit the current IAM role, create a new one, or select a different role."
This message is standard. Choose Save anyway.
- On the New execution page, choose Start Execution again.
- On the next page, in the visual workflow pane, examine the individual steps that define your workflow.
- Optional - To export the graph of your workflow to an SVG or PNG file, choose Export.
- To view the results of your execution, in the visual workflow pane, choose World, and then, under Step details, choose Output.
The output is World has been updated!
Step 4: Delete state machine
In some cases, you might need to delete your state machine and execution role.
If you're done with this tutorial, delete your state machine and the execution role that Step Functions created for you.
To delete your state machine
- From the navigation menu, choose State machines.
- On the State machines page, under State machines, select Helloworld, and then choose Delete.
After you choose Delete, the following message appears:
“You are about to delete your state machine. Do you want to proceed?”
This message is standard. Choose Delete state machine.
A green status bar appears at the top of your screen. The green status bar tells you that your state machine is marked for deletion. Your state machine will be removed when all of its executions stop running.
To delete your execution role
- Open the Roles page for IAM.
- Choose the IAM role that Step Functions created for you: StepFunctions-Helloworld-role-EXAMPLE.
- Choose Delete role.
- Choose Yes, delete.
Now that you completed this tutorial, you know how to create, test, debug, and delete a state machine.
Third Rock Techkno is a leading IT services company. We are a top-ranked web, voice and mobile app development company with over 10 years of experience. Client success forms the core of our value system.
We have expertise in the latest technologies including angular, react native, iOs, Android and more. Third Rock Techkno has developed smart, scalable and innovative solutions for clients across a host of industries.
Our team of dedicated developers combine their knowledge and skills to develop and deliver web and mobile apps that boost business and increase output for our clients.