AWS::StepFunctions::StateMachine
Use the AWS::StepFunctions::StateMachine resource to create an AWS Step Functions state
machine.
For information about creating state machines, see Tutorial: A Lambda State Machine in the
AWS Step Functions Developer Guide and CreateStateMachine in the
AWS Step Functions API Reference.
Syntax
JSON
{ "Type": "AWS::StepFunctions::StateMachine", "Properties": { "StateMachineName":String, "DefinitionString":String, "RoleArn":String} }
YAML
Type: "AWS::StepFunctions::StateMachine" Properties: StateMachineName:StringDefinitionString:StringRoleArn:String
Properties
StateMachineName-
The name of the state machine. If you do not specify a name one will be generated that is similar to
MyStateMachine-1234abcdefgh. For more information on creating a valid name see Request Parameters in the AWS Step Functions API Reference.Required: No
Type: String
Update requires: Replacement
DefinitionString-
The Amazon States Language definition of the state machine. For more information, see Amazon States Language in the AWS Step Functions Developer Guide.
Required: Yes
Type: String
Update requires: No interruption
RoleArn-
The Amazon Resource Name (ARN) of the IAM role to use for this state machine.
Required: Yes
Type: String
Update requires: No interruption
Return Values
Ref
When you provide the logical ID of this resource to the Ref intrinsic
function, Ref returns the ARN of the created state machine. For
example:
{ "Ref": "MyStateMachine" }
Returns a value similar to the following:
arn:aws:states:us-east-1:111122223333:stateMachine:HelloWorld-StateMachine
For more information about using the Ref function, see Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type.
The following are the available attributes and sample return values.
Name-
Returns the name of the state machine. For example:
{ "Fn::GetAtt": ["MyStateMachine", "Name"] }Returns the name of your state machine:
HelloWorld-StateMachineIf you did not specify the name it will be similar to the following:
MyStateMachine-1234abcdefgh
For more information about using Fn::GetAtt, see Fn::GetAtt.
Examples
The following examples create a Step Functions state machine.
JSON
Using a Single-Line Property
{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "An example template for a Step Functions state machine.", "Resources" : { "MyStateMachine" : { "Type" : "AWS::StepFunctions::StateMachine", "Properties" : { "StateMachineName" : "HelloWorld-StateMachine", "DefinitionString" : "{\"StartAt\": \"HelloWorld\", \"States\": {\"HelloWorld\": {\"Type\": \"Task\", \"Resource\": \"arn:aws:lambda:us-east-1:111122223333:function:HelloFunction\", \"End\": true}}}", "RoleArn" : "arn:aws:iam::111122223333:role/service-role/StatesExecutionRole-us-east-1" } } } }
Using the Fn::Join Intrinsic Function
{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "An example template for a Step Functions state machine.", "Resources": { "MyStateMachine": { "Type": "AWS::StepFunctions::StateMachine", "Properties": { "StateMachineName" : "HelloWorld-StateMachine", "DefinitionString" : { "Fn::Join": [ "\n", [ "{", " \"StartAt\": \"HelloWorld\",", " \"States\" : {", " \"HelloWorld\" : {", " \"Type\" : \"Task\", ", " \"Resource\" : \"arn:aws:lambda:us-east-1:111122223333:function:HelloFunction\",", " \"End\" : true", " }", " }", "}" ] ] }, "RoleArn" : "arn:aws:iam::111122223333:role/service-role/StatesExecutionRole-us-east-1" } } } }
YAML
AWSTemplateFormatVersion: '2010-09-09' Description: An example template for a Step Functions state machine. Resources: MyStateMachine: Type: AWS::StepFunctions::StateMachine Properties: StateMachineName: HelloWorld-StateMachine DefinitionString: |- { "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:111122223333:function:HelloFunction", "End": true } } } RoleArn: arn:aws:iam::111122223333:role/service-role/StatesExecutionRole-us-east-1
