Working with AWS Step Functions
The following sections describe how to work with AWS Step Functions Amazon State Language (ASL)
files containing state machine definitions in the AWS Toolkit. For detailed information about AWS Step Functions state machines, see the Learn about state machines in Step Functions topic in the AWS Step Functions Developer Guide.
Viewing Step Functions state machines
To view your existing ASL
files containing state machine definitions in the AWS Toolkit Explorer, complete the following steps.
From the AWS Toolkit Explorer, expand the region that contains the
ASL
file that you want to view.Expand the Step Functions heading.
Your
ASL
files are displayed in the AWS Explorer.
Creating a Step Functions state machine
In the AWS Toolkit, you can create a new Step Functions state machine from a file or you can use a template. The following procedure describes how to create a Step Functions state machine from a file. For details about creating a SFN; state machine from a template, see the State machine templates section located below, in this User Guide topic.
Note
To work with Step Functions in VS Code, the extension of your Amazon State
Language
(ASL) file that contains your state machine definition must
end with asl.json
, asl.yml
, or .asl.yaml
.
By default, relevant Step Functions files open in Workflow Studio. For detailed information about working in Workflow Studio through the AWS Toolkit, see the Working with Workflow Studio topic in this User Guide.
From your workspace in VS Code, create a new file.
Name your file and specify the file extension as
asl.json
,asl.yml
, or.asl.yaml
.Upon creation, the AWS Toolkit opens the new file in AWS Step Functions Workflow Studio.
From Workflow Studio choose the Save button from the utility menu to save your new
ASL
file.
Creating a Step Functions state machine from a template
In the AWS Toolkit, you can create a Step Functions state machine from a template. The
template process creates a ASL
file that contains a state machine definition, providing a starting point for your project. The following procedure describes how to create a Step Functions state machine from a template in the AWS Toolkit.
From the AWS Toolkit Explorer, expand the region that you want to create a Step Functions state machine in.
Open the context menu for (right-click) Step Functions and choose Create a new Step Functions state machine to open the Select a starter template(1/2) wizard in VS Code.
From the Select a starter template(1/2) wizard, choose the template type for your Step Functions state machine to proceed.
From the Select template format(2/2) screen, choose either YAML or JSON for your template format.
A new
ASL
file containing your state machine definition is opened in the VS Code editor.
Downloading a Step Functions state machine
To download a remotely stored Step Functions state machine to your local instance of VS Code, complete the following steps.
From the AWS Toolkit Explorer, expand the region that contains the Step Functions state machine that your want to download.
Expand Step Functions, then right-click the Step Functions state machine you want to download and choose Download Definition....
Specify a location to store your Step Functions state machine locally to proceed.
The Step Functions state machine opens in Workflow Studio when the procedure is complete.
Saving changes to a Step Functions state machine
The following procedure describes how to save changes made to your Step Functions state machine.
Note
Edits made in Workflow Studio sync to your local file, but remain unsaved until your work is saved in the VS Code editor or Workflow Studio. If you local file is modified and saved while Workflow Studio is open and there are no errors detected in your ASL
file, then you receive a Success notification in Workflow Studio, when saving is complete. However, if your local file contains invalid JSON
or YAML
and you attempt to save, then your local file fails to sync and you receive a Warning notification in Workflow Studio.
From an open
ASL
file containing a state machine definition in Workflow Studio, navigate to the Utility buttons.Choose the Save button.
VS Code notifies you when the file has been saved.
Running a Step Functions state machine
The following procedure describes how to run a Step Functions state machine in the AWS Toolkit.
From the AWS Toolkit Explorer, expand the region containing the Step Functions state machine that you want to run.
Expand Step Functions, then right-click the Step Functions state machine that you want to run.
From the context menu, choose Start Execution to initiate the launch process.
The status of the launch is displayed in the AWS Toolkit Output window in VS Code.
Working with code snippets
Code snippets are automated suggestions that generate based on the code that you're working on. To work with code snippets with Step Functions in the toolkit, complete the following steps.
Note
To work with Step Functions code snippets in VS Code, the extension of your ASL
file that contains your state machine definition must end with .asl.json
, .asl.yml
, or .asl.yaml
.
By default, your relevant Step Functions files open in Workflow Studio.
From VS Code, open an
ASL
file containing the state machine definition that you want to modify or create a newASL
file.From Workflow Studio, switch to Code mode if you're in Design mode.
From the Workflow Studio code editor, place your cursor in the
"States"
property.Press
control + space
to open the code snippets menu, additional properties can be accessed by pressingcontrol + space
and are based on the"State"
"Type"
.Choose the code snippet that you want from the list.
Code validation
As you work on Step Functions in Workflow Studio, code validation actively identifies errors and makes suggestions for the following:
-
Missing properties
-
Incorrect values
-
Non terminal state
-
Nonexistent states that are pointed to