Resource: awsSfnStateMachine
Provides a Step Function State Machine resource
Example Usage
Basic (Standard Workflow)
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.sfnStateMachine.SfnStateMachine(this, "sfn_state_machine", {
definition:
'{\n "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",\n "StartAt": "HelloWorld",\n "States": {\n "HelloWorld": {\n "Type": "Task",\n "Resource": "${aws_lambda_function.lambda.arn}",\n "End": true\n }\n }\n}\n',
name: "my-state-machine",
roleArn: "${aws_iam_role.iam_for_sfn.arn}",
});
Basic (Express Workflow)
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.sfnStateMachine.SfnStateMachine(this, "sfn_state_machine", {
definition:
'{\n "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",\n "StartAt": "HelloWorld",\n "States": {\n "HelloWorld": {\n "Type": "Task",\n "Resource": "${aws_lambda_function.lambda.arn}",\n "End": true\n }\n }\n}\n',
name: "my-state-machine",
roleArn: "${aws_iam_role.iam_for_sfn.arn}",
type: "EXPRESS",
});
Logging
\~> NOTE: See the AWS Step Functions Developer Guide for more information about enabling Step Function logging.
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.sfnStateMachine.SfnStateMachine(this, "sfn_state_machine", {
definition:
'{\n "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",\n "StartAt": "HelloWorld",\n "States": {\n "HelloWorld": {\n "Type": "Task",\n "Resource": "${aws_lambda_function.lambda.arn}",\n "End": true\n }\n }\n}\n',
loggingConfiguration: {
includeExecutionData: true,
level: "ERROR",
logDestination: "${aws_cloudwatch_log_group.log_group_for_sfn.arn}:*",
},
name: "my-state-machine",
roleArn: "${aws_iam_role.iam_for_sfn.arn}",
});
Argument Reference
The following arguments are supported:
definition
- (Required) The Amazon States Language definition of the state machine.loggingConfiguration
- (Optional) Defines what execution history events are logged and where they are logged. TheloggingConfiguration
parameter is only valid whentype
is set toexpress
. Defaults tooff
. 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 contain0
-9
,a
-z
,a
-z
,-
and_
. If omitted, Terraform will assign a random, unique name.namePrefix
- (Optional) Creates a unique name beginning with the specified prefix. Conflicts withname
.roleArn
- (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 providerdefaultTags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.tracingConfiguration
- (Optional) Selects whether AWS X-Ray tracing is enabled.type
- (Optional) Determines whether a Standard or Express state machine is created. The default isstandard
. You cannot update the type of a state machine once it has been created. Valid values:standard
,express
.
loggingConfiguration
Configuration Block
includeExecutionData
- (Optional) Determines whether execution data is included in your log. When set tofalse
, data is excluded.level
- (Optional) Defines which category of execution history events are logged. Valid values:all
,error
,fatal
,off
logDestination
- (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:*
tracingConfiguration
Configuration Block
enabled
- (Optional) When set totrue
, 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.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
id
- The ARN of the state machine.arn
- The ARN of the state machine.creationDate
- The date the state machine was created.status
- The current status of the state machine. Eitheractive
ordeleting
.tagsAll
- A map of tags assigned to the resource, including those inherited from the providerdefaultTags
configuration block.
Import
State Machines can be imported using the arn
, e.g.,