State Machine
    Provides a Step Function State Machine resource
Example Usage
Basic (Standard Workflow)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// ...
const sfnStateMachine = new aws.sfn.StateMachine("sfn_state_machine", {
    name: "my-state-machine",
    roleArn: iamForSfn.arn,
    definition: `{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "${lambda.arn}",
      "End": true
    }
  }
}
`,
});Content copied to clipboard
import pulumi
import pulumi_aws as aws
# ...
sfn_state_machine = aws.sfn.StateMachine("sfn_state_machine",
    name="my-state-machine",
    role_arn=iam_for_sfn["arn"],
    definition=f"""{{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {{
    "HelloWorld": {{
      "Type": "Task",
      "Resource": "{lambda_["arn"]}",
      "End": true
    }}
  }}
}}
""")Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
    // ...
    var sfnStateMachine = new Aws.Sfn.StateMachine("sfn_state_machine", new()
    {
        Name = "my-state-machine",
        RoleArn = iamForSfn.Arn,
        Definition = @$"{{
  ""Comment"": ""A Hello World example of the Amazon States Language using an AWS Lambda Function"",
  ""StartAt"": ""HelloWorld"",
  ""States"": {{
    ""HelloWorld"": {{
      ""Type"": ""Task"",
      ""Resource"": ""{lambda.Arn}"",
      ""End"": true
    }}
  }}
}}
",
    });
});Content copied to clipboard
package main
import (
	"fmt"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sfn"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// ...
		_, err := sfn.NewStateMachine(ctx, "sfn_state_machine", &sfn.StateMachineArgs{
			Name:    pulumi.String("my-state-machine"),
			RoleArn: pulumi.Any(iamForSfn.Arn),
			Definition: pulumi.String(fmt.Sprintf(`{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%v",
      "End": true
    }
  }
}
`, lambda.Arn)),
		})
		if err != nil {
			return err
		}
		return nil
	})
}Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.sfn.StateMachine;
import com.pulumi.aws.sfn.StateMachineArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        // ...
        var sfnStateMachine = new StateMachine("sfnStateMachine", StateMachineArgs.builder()
            .name("my-state-machine")
            .roleArn(iamForSfn.arn())
            .definition("""
{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%s",
      "End": true
    }
  }
}
", lambda.arn()))
            .build());
    }
}Content copied to clipboard
resources:
  # ...
  sfnStateMachine:
    type: aws:sfn:StateMachine
    name: sfn_state_machine
    properties:
      name: my-state-machine
      roleArn: ${iamForSfn.arn}
      definition: |
        {
          "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
          "StartAt": "HelloWorld",
          "States": {
            "HelloWorld": {
              "Type": "Task",
              "Resource": "${lambda.arn}",
              "End": true
            }
          }
        }Content copied to clipboard
Basic (Express Workflow)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// ...
const sfnStateMachine = new aws.sfn.StateMachine("sfn_state_machine", {
    name: "my-state-machine",
    roleArn: iamForSfn.arn,
    type: "EXPRESS",
    definition: `{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "${lambda.arn}",
      "End": true
    }
  }
}
`,
});Content copied to clipboard
import pulumi
import pulumi_aws as aws
# ...
sfn_state_machine = aws.sfn.StateMachine("sfn_state_machine",
    name="my-state-machine",
    role_arn=iam_for_sfn["arn"],
    type="EXPRESS",
    definition=f"""{{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {{
    "HelloWorld": {{
      "Type": "Task",
      "Resource": "{lambda_["arn"]}",
      "End": true
    }}
  }}
}}
""")Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
    // ...
    var sfnStateMachine = new Aws.Sfn.StateMachine("sfn_state_machine", new()
    {
        Name = "my-state-machine",
        RoleArn = iamForSfn.Arn,
        Type = "EXPRESS",
        Definition = @$"{{
  ""Comment"": ""A Hello World example of the Amazon States Language using an AWS Lambda Function"",
  ""StartAt"": ""HelloWorld"",
  ""States"": {{
    ""HelloWorld"": {{
      ""Type"": ""Task"",
      ""Resource"": ""{lambda.Arn}"",
      ""End"": true
    }}
  }}
}}
",
    });
});Content copied to clipboard
package main
import (
	"fmt"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sfn"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// ...
		_, err := sfn.NewStateMachine(ctx, "sfn_state_machine", &sfn.StateMachineArgs{
			Name:    pulumi.String("my-state-machine"),
			RoleArn: pulumi.Any(iamForSfn.Arn),
			Type:    pulumi.String("EXPRESS"),
			Definition: pulumi.String(fmt.Sprintf(`{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%v",
      "End": true
    }
  }
}
`, lambda.Arn)),
		})
		if err != nil {
			return err
		}
		return nil
	})
}Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.sfn.StateMachine;
import com.pulumi.aws.sfn.StateMachineArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        // ...
        var sfnStateMachine = new StateMachine("sfnStateMachine", StateMachineArgs.builder()
            .name("my-state-machine")
            .roleArn(iamForSfn.arn())
            .type("EXPRESS")
            .definition("""
{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%s",
      "End": true
    }
  }
}
", lambda.arn()))
            .build());
    }
}Content copied to clipboard
resources:
  # ...
  sfnStateMachine:
    type: aws:sfn:StateMachine
    name: sfn_state_machine
    properties:
      name: my-state-machine
      roleArn: ${iamForSfn.arn}
      type: EXPRESS
      definition: |
        {
          "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
          "StartAt": "HelloWorld",
          "States": {
            "HelloWorld": {
              "Type": "Task",
              "Resource": "${lambda.arn}",
              "End": true
            }
          }
        }Content copied to clipboard
Publish (Publish SFN version)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// ...
const sfnStateMachine = new aws.sfn.StateMachine("sfn_state_machine", {
    name: "my-state-machine",
    roleArn: iamForSfn.arn,
    publish: true,
    type: "EXPRESS",
    definition: `{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "${lambda.arn}",
      "End": true
    }
  }
}
`,
});Content copied to clipboard
import pulumi
import pulumi_aws as aws
# ...
sfn_state_machine = aws.sfn.StateMachine("sfn_state_machine",
    name="my-state-machine",
    role_arn=iam_for_sfn["arn"],
    publish=True,
    type="EXPRESS",
    definition=f"""{{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {{
    "HelloWorld": {{
      "Type": "Task",
      "Resource": "{lambda_["arn"]}",
      "End": true
    }}
  }}
}}
""")Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
    // ...
    var sfnStateMachine = new Aws.Sfn.StateMachine("sfn_state_machine", new()
    {
        Name = "my-state-machine",
        RoleArn = iamForSfn.Arn,
        Publish = true,
        Type = "EXPRESS",
        Definition = @$"{{
  ""Comment"": ""A Hello World example of the Amazon States Language using an AWS Lambda Function"",
  ""StartAt"": ""HelloWorld"",
  ""States"": {{
    ""HelloWorld"": {{
      ""Type"": ""Task"",
      ""Resource"": ""{lambda.Arn}"",
      ""End"": true
    }}
  }}
}}
",
    });
});Content copied to clipboard
package main
import (
	"fmt"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sfn"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// ...
		_, err := sfn.NewStateMachine(ctx, "sfn_state_machine", &sfn.StateMachineArgs{
			Name:    pulumi.String("my-state-machine"),
			RoleArn: pulumi.Any(iamForSfn.Arn),
			Publish: pulumi.Bool(true),
			Type:    pulumi.String("EXPRESS"),
			Definition: pulumi.String(fmt.Sprintf(`{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%v",
      "End": true
    }
  }
}
`, lambda.Arn)),
		})
		if err != nil {
			return err
		}
		return nil
	})
}Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.sfn.StateMachine;
import com.pulumi.aws.sfn.StateMachineArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        // ...
        var sfnStateMachine = new StateMachine("sfnStateMachine", StateMachineArgs.builder()
            .name("my-state-machine")
            .roleArn(iamForSfn.arn())
            .publish(true)
            .type("EXPRESS")
            .definition("""
{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%s",
      "End": true
    }
  }
}
", lambda.arn()))
            .build());
    }
}Content copied to clipboard
resources:
  # ...
  sfnStateMachine:
    type: aws:sfn:StateMachine
    name: sfn_state_machine
    properties:
      name: my-state-machine
      roleArn: ${iamForSfn.arn}
      publish: true
      type: EXPRESS
      definition: |
        {
          "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
          "StartAt": "HelloWorld",
          "States": {
            "HelloWorld": {
              "Type": "Task",
              "Resource": "${lambda.arn}",
              "End": true
            }
          }
        }Content copied to clipboard
Logging
NOTE: See the AWS Step Functions Developer Guide for more information about enabling Step Function logging.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// ...
const sfnStateMachine = new aws.sfn.StateMachine("sfn_state_machine", {
    name: "my-state-machine",
    roleArn: iamForSfn.arn,
    definition: `{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "${lambda.arn}",
      "End": true
    }
  }
}
`,
    loggingConfiguration: {
        logDestination: `${logGroupForSfn.arn}:*`,
        includeExecutionData: true,
        level: "ERROR",
    },
});Content copied to clipboard
import pulumi
import pulumi_aws as aws
# ...
sfn_state_machine = aws.sfn.StateMachine("sfn_state_machine",
    name="my-state-machine",
    role_arn=iam_for_sfn["arn"],
    definition=f"""{{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {{
    "HelloWorld": {{
      "Type": "Task",
      "Resource": "{lambda_["arn"]}",
      "End": true
    }}
  }}
}}
""",
    logging_configuration=aws.sfn.StateMachineLoggingConfigurationArgs(
        log_destination=f"{log_group_for_sfn['arn']}:*",
        include_execution_data=True,
        level="ERROR",
    ))Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
    // ...
    var sfnStateMachine = new Aws.Sfn.StateMachine("sfn_state_machine", new()
    {
        Name = "my-state-machine",
        RoleArn = iamForSfn.Arn,
        Definition = @$"{{
  ""Comment"": ""A Hello World example of the Amazon States Language using an AWS Lambda Function"",
  ""StartAt"": ""HelloWorld"",
  ""States"": {{
    ""HelloWorld"": {{
      ""Type"": ""Task"",
      ""Resource"": ""{lambda.Arn}"",
      ""End"": true
    }}
  }}
}}
",
        LoggingConfiguration = new Aws.Sfn.Inputs.StateMachineLoggingConfigurationArgs
        {
            LogDestination = $"{logGroupForSfn.Arn}:*",
            IncludeExecutionData = true,
            Level = "ERROR",
        },
    });
});Content copied to clipboard
package main
import (
	"fmt"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sfn"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// ...
		_, err := sfn.NewStateMachine(ctx, "sfn_state_machine", &sfn.StateMachineArgs{
			Name:    pulumi.String("my-state-machine"),
			RoleArn: pulumi.Any(iamForSfn.Arn),
			Definition: pulumi.String(fmt.Sprintf(`{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%v",
      "End": true
    }
  }
}
`, lambda.Arn)),
			LoggingConfiguration: &sfn.StateMachineLoggingConfigurationArgs{
				LogDestination:       pulumi.String(fmt.Sprintf("%v:*", logGroupForSfn.Arn)),
				IncludeExecutionData: pulumi.Bool(true),
				Level:                pulumi.String("ERROR"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.sfn.StateMachine;
import com.pulumi.aws.sfn.StateMachineArgs;
import com.pulumi.aws.sfn.inputs.StateMachineLoggingConfigurationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        // ...
        var sfnStateMachine = new StateMachine("sfnStateMachine", StateMachineArgs.builder()
            .name("my-state-machine")
            .roleArn(iamForSfn.arn())
            .definition("""
{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Task",
      "Resource": "%s",
      "End": true
    }
  }
}
", lambda.arn()))
            .loggingConfiguration(StateMachineLoggingConfigurationArgs.builder()
                .logDestination(String.format("%s:*", logGroupForSfn.arn()))
                .includeExecutionData(true)
                .level("ERROR")
                .build())
            .build());
    }
}Content copied to clipboard
resources:
  # ...
  sfnStateMachine:
    type: aws:sfn:StateMachine
    name: sfn_state_machine
    properties:
      name: my-state-machine
      roleArn: ${iamForSfn.arn}
      definition: |
        {
          "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
          "StartAt": "HelloWorld",
          "States": {
            "HelloWorld": {
              "Type": "Task",
              "Resource": "${lambda.arn}",
              "End": true
            }
          }
        }
      loggingConfiguration:
        logDestination: ${logGroupForSfn.arn}:*
        includeExecutionData: true
        level: ERRORContent copied to clipboard
Import
Using pulumi import, import State Machines using the arn. For example:
$ pulumi import aws:sfn/stateMachine:StateMachine foo arn:aws:states:eu-west-1:123456789098:stateMachine:barContent copied to clipboard
Properties
Link copied to clipboard
                Link copied to clipboard
                Link copied to clipboard
                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.
Link copied to clipboard