Provides a Step Function State Machine resource
# ...
resource "aws_sfn_state_machine" "sfn_state_machine" {
name = "my-state-machine"
role_arn = aws_iam_role.iam_for_sfn.arn
definition = <<EOF
{
"Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "${aws_lambda_function.lambda.arn}",
"End": true
}
}
}
EOF
}
# ...
resource "aws_sfn_state_machine" "sfn_state_machine" {
name = "my-state-machine"
role_arn = aws_iam_role.iam_for_sfn.arn
type = "EXPRESS"
definition = <<EOF
{
"Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "${aws_lambda_function.lambda.arn}",
"End": true
}
}
}
EOF
}
# ...
resource "aws_sfn_state_machine" "sfn_state_machine" {
name = "my-state-machine"
role_arn = aws_iam_role.iam_for_sfn.arn
publish = true
type = "EXPRESS"
definition = <<EOF
{
"Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "${aws_lambda_function.lambda.arn}",
"End": true
}
}
}
EOF
}
# ...
resource "aws_sfn_state_machine" "sfn_state_machine" {
name = "my-state-machine"
role_arn = aws_iam_role.iam_for_sfn.arn
definition = <<EOF
{
"Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "${aws_lambda_function.lambda.arn}",
"End": true
}
}
}
EOF
logging_configuration {
log_destination = "${aws_cloudwatch_log_group.log_group_for_sfn.arn}:*"
include_execution_data = true
level = "ERROR"
}
}
This resource supports the following arguments:
definition
- (Required) The Amazon States Language definition of the state machine.logging_configuration
- (Optional) Defines what execution history events are logged and where they are logged. The logging_configuration
parameter is only valid when type
is set to EXPRESS
. Defaults to OFF
. For more information see Logging Express Workflows and Log Levels in the AWS Step Functions User Guide.name
- (Optional) The name of the state machine. The name should only contain 0
-9
, A
-Z
, a
-z
, -
and _
. If omitted, Terraform will assign a random, unique name.name_prefix
- (Optional) Creates a unique name beginning with the specified prefix. Conflicts with name
.publish
- (Optional) Set to true to publish a version of the state machine during creation. Default: false.role_arn
- (Required) The Amazon Resource Name (ARN) of the IAM role to use for this state machine.tags
- (Optional) Key-value map of resource tags. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.tracing_configuration
- (Optional) Selects whether AWS X-Ray tracing is enabled.type
- (Optional) Determines whether a Standard or Express state machine is created. The default is STANDARD
. You cannot update the type of a state machine once it has been created. Valid values: STANDARD
, EXPRESS
.logging_configuration
Configuration Blockinclude_execution_data
- (Optional) Determines whether execution data is included in your log. When set to false
, data is excluded.level
- (Optional) Defines which category of execution history events are logged. Valid values: ALL
, ERROR
, FATAL
, OFF
log_destination
- (Optional) Amazon Resource Name (ARN) of a CloudWatch log group. Make sure the State Machine has the correct IAM policies for logging. The ARN must end with :*
tracing_configuration
Configuration Blockenabled
- (Optional) When set to true
, AWS X-Ray tracing is enabled. Make sure the State Machine has the correct IAM policies for logging. See the AWS Step Functions Developer Guide for details.This resource exports the following attributes in addition to the arguments above:
id
- The ARN of the state machine.arn
- The ARN of the state machine.creation_date
- The date the state machine was created.state_machine_version_arn
- The ARN of the state machine version.status
- The current status of the state machine. Either ACTIVE
or DELETING
.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.create
- (Default 5m
)update
- (Default 1m
)delete
- (Default 5m
)In Terraform v1.5.0 and later, use an import
block to import State Machines using the arn
. For example:
import {
to = aws_sfn_state_machine.foo
id = "arn:aws:states:eu-west-1:123456789098:stateMachine:bar"
}
Using terraform import
, import State Machines using the arn
. For example:
% terraform import aws_sfn_state_machine.foo arn:aws:states:eu-west-1:123456789098:stateMachine:bar