Skip to content
Get Started for Free

Simple Workflow Service (SWF)

Simple Workflow Service (SWF) is a fully managed service offered by Amazon Web Services (AWS) that enables you to build and manage applications with distributed components and complex workflows. SWF allows you to define workflows in a way that’s separate from the actual application code, making it easier to modify and adapt workflows without changing the application logic. SWF also provides a programming framework to design, coordinate, and execute workflows that involve multiple tasks, steps, and decision points.

LocalStack allows you to use the SWF APIs in your local environment to monitor and manage workflow design, task coordination, activity implementation, and error handling. The supported APIs are available on our API Coverage section, which provides information on the extent of SWF’s integration with LocalStack.

This guide is designed for users new to Simple Workflow Service and assumes basic knowledge of the AWS CLI and our lstk aws command.

Start your LocalStack container using your preferred method. We will demonstrate how to register an SWF domain and workflow using the AWS CLI.

You can register an SWF domain using the RegisterDomain API. Execute the following command to register a domain named test-domain:

Terminal window
lstk aws swf register-domain \
--name test-domain \
--workflow-execution-retention-period-in-days 1

You can use the DescribeDomain API to verify that the domain was registered successfully. Run the following command to describe the test-domain domain:

Terminal window
lstk aws swf describe-domain \
--name test-domain
Output
{
"domainInfo": {
"name": "test-domain",
"status": "REGISTERED",
"arn": "arn:aws:swf:us-east-1:000000000000:/domain/test-domain"
},
"configuration": {
"workflowExecutionRetentionPeriodInDays": "1"
}
}

You can list all registered domains using the ListDomains API. Run the following command to list all registered domains:

Terminal window
lstk aws swf list-domains --registration-status REGISTERED

To deprecate a domain, use the DeprecateDomain API. Run the following command to deprecate the test-domain domain:

Terminal window
lstk aws swf deprecate-domain \
--name test-domain

You can now list the deprecated domains using the --registration-status DEPRECATED flag:

Terminal window
lstk aws swf list-domains --registration-status DEPRECATED

You can register a workflow using the RegisterWorkflowType API. Execute the following command to register a workflow named test-workflow:

Terminal window
lstk aws swf register-workflow-type \
--domain test-domain \
--name test-workflow \
--default-task-list name=test-task-list \
--default-task-start-to-close-timeout 30 \
--default-execution-start-to-close-timeout 60 \
--default-child-policy TERMINATE \
--workflow-version "1.0"

You can use the DescribeWorkflowType API to verify that the workflow was registered successfully. Run the following command to describe the test-workflow workflow:

Terminal window
lstk aws swf describe-workflow-type \
--domain test-domain \
--workflow-type name=test-workflow,version=1.0

The following output would be retrieved:

Output
{
"typeInfo": {
"workflowType": {
"name": "test-workflow",
"version": "1.0"
},
"status": "REGISTERED",
"creationDate": 1420066800.0
},
"configuration": {
"defaultTaskStartToCloseTimeout": "30",
"defaultExecutionStartToCloseTimeout": "60",
"defaultTaskList": {
"name": "test-task-list"
},
"defaultChildPolicy": "TERMINATE"
}
}

You can register an activity using the RegisterActivityType API. Execute the following command to register an activity named test-activity:

Terminal window
lstk aws swf register-activity-type \
--domain test-domain \
--name test-activity \
--default-task-list name=test-task-list \
--default-task-start-to-close-timeout 30 \
--default-task-heartbeat-timeout 30 \
--default-task-schedule-to-start-timeout 30 \
--default-task-schedule-to-close-timeout 30 \
--activity-version "1.0"

You can use the DescribeActivityType API to verify that the activity was registered successfully. Run the following command to describe the test-activity activity:

Terminal window
lstk aws swf describe-activity-type \
--domain test-domain \
--activity-type name=test-activity,version=1.0

The following output would be retrieved:

Output
{
"typeInfo": {
"activityType": {
"name": "test-activity",
"version": "1.0"
},
"status": "REGISTERED",
"creationDate": 1420066800.0
},
"configuration": {
"defaultTaskStartToCloseTimeout": "30",
"defaultTaskHeartbeatTimeout": "30",
"defaultTaskList": {
"name": "test-task-list"
},
"defaultTaskScheduleToStartTimeout": "30",
"defaultTaskScheduleToCloseTimeout": "30"
}
}

You can start a workflow execution using the StartWorkflowExecution API. Execute the following command to start a workflow execution for the test-workflow workflow:

Terminal window
lstk aws swf start-workflow-execution \
--domain test-domain \
--workflow-type name=test-workflow,version=1.0 \
--workflow-id test-workflow-id \
--task-list name=test-task-list \
--input '{"foo": "bar"}'

The following output would be retrieved:

Output
{
"runId": "0602601afc71403abb934d8094c51668"
}

30 of 39 operations implemented

Available from the Hobby plan. Licensing details

Find an API

Search the full operation list, then sort the table to compare current support.

Loading operations…

Verified on Kubernetes
Loading operations…
Complete static API list All 39 operations and their current support status
OperationStatus
CountClosedWorkflowExecutionsNot implemented
CountOpenWorkflowExecutionsNot implemented
CountPendingActivityTasksImplemented
CountPendingDecisionTasksImplemented
DeleteActivityTypeNot implemented
DeleteWorkflowTypeNot implemented
DeprecateActivityTypeImplemented
DeprecateDomainImplemented
DeprecateWorkflowTypeImplemented
DescribeActivityTypeImplemented
DescribeDomainImplemented
DescribeWorkflowExecutionImplemented
DescribeWorkflowTypeImplemented
GetWorkflowExecutionHistoryImplemented
ListActivityTypesImplemented
ListClosedWorkflowExecutionsImplemented
ListDomainsImplemented
ListOpenWorkflowExecutionsImplemented
ListTagsForResourceNot implemented
ListWorkflowTypesImplemented
PollForActivityTaskImplemented
PollForDecisionTaskImplemented
RecordActivityTaskHeartbeatImplemented
RegisterActivityTypeImplemented
RegisterDomainImplemented
RegisterWorkflowTypeImplemented
RequestCancelWorkflowExecutionNot implemented
RespondActivityTaskCanceledNot implemented
RespondActivityTaskCompletedImplemented
RespondActivityTaskFailedImplemented
RespondDecisionTaskCompletedImplemented
SignalWorkflowExecutionImplemented
StartWorkflowExecutionImplemented
TagResourceNot implemented
TerminateWorkflowExecutionImplemented
UndeprecateActivityTypeImplemented
UndeprecateDomainImplemented
UndeprecateWorkflowTypeImplemented
UntagResourceNot implemented
Was this page helpful?