StateGraph Class
A collection of connected states.
A StateGraph is used to keep track of all states that are connected (have transitions between them). It does not include the substatemachines in a Parallel's branches: those are their own StateGraphs, but the graphs themselves have a hierarchical relationship as well.
By assigning states to a definitive StateGraph, we verify that no state machines are constructed. In particular:
- Every state object can only ever be in 1 StateGraph, and not inadvertently be used in two graphs.
- Every stateId must be unique across all states in the entire state machine.
All policy statements in all states in all substatemachines are bubbled so that the top-level StateMachine instantiation can read them all and add them to the IAM Role.
You do not need to instantiate this class; it is used internally.
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_stepfunctions as stepfunctions } from 'aws-cdk-lib';
declare const state: stepfunctions.State;
const stateGraph = new stepfunctions.StateGraph(state, 'graphDescription');
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_stepfunctions as stepfunctions
# state: stepfunctions.State
state_graph = stepfunctions.StateGraph(state, "graphDescription")
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.stepfunctions.*;
State state;
StateGraph stateGraph = new StateGraph(state, "graphDescription");
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.StepFunctions;
State state;
var stateGraph = new StateGraph(state, "graphDescription");
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
var state State
stateGraph := awscdk.Aws_stepfunctions.NewStateGraph(state, jsii.String("graphDescription"))
Initializer
ts
new StateGraph(startState: State, graphDescription: string)
python
StateGraph(start_state: State, graph_description: str)
java
new StateGraph(State startState, String graphDescription)
csharp
new StateGraph(State startState, string graphDescription)
go
NewStateGraph(StartState State, GraphDescription *string)
Properties
policyStatementsPolicyStatement[]policy_statementstyping.List[PolicyStatement]policyStatementsList<PolicyStatement>PolicyStatementsPolicyStatement[]PolicyStatements*[]PolicyStatementrequired#The accumulated policy statements.
state that gets executed when the state machine is launched.
Methods
bind(stateMachine: StateMachine): voiddef bind(self, state_machine: StateMachine) -> Nonepublic void bind(StateMachine stateMachine)public void Bind(StateMachine stateMachine)func Bind(StateMachine StateMachine)#Binds this StateGraph to the StateMachine it defines and updates state machine permissions if there are DistributedMap states.
registerPolicyStatement(statement: PolicyStatement): voiddef register_policy_statement(self, statement: PolicyStatement) -> Nonepublic void registerPolicyStatement(PolicyStatement statement)public void RegisterPolicyStatement(PolicyStatement statement)func RegisterPolicyStatement(Statement PolicyStatement)#Register a Policy Statement used by states in this graph.
registerState(state: State): voiddef register_state(self, state: State) -> Nonepublic void registerState(State state)public void RegisterState(State state)func RegisterState(State State)#Register a state as part of this graph.
Called by State.bindToGraph().
registerSuperGraph(graph: StateGraph): voiddef register_super_graph(self, graph: StateGraph) -> Nonepublic void registerSuperGraph(StateGraph graph)public void RegisterSuperGraph(StateGraph graph)func RegisterSuperGraph(Graph StateGraph)#Register this graph as a child of the given graph.
Resource changes will be bubbled up to the given graph.
toGraphJson(queryLanguage?: QueryLanguage): jsondef to_graph_json(self, query_language: typing.Optional[QueryLanguage] = None) -> Anypublic Object toGraphJson(QueryLanguage queryLanguage)public object ToGraphJson(QueryLanguage? queryLanguage = null)func ToGraphJson(QueryLanguage QueryLanguage) interface{}#Return the Amazon States Language JSON for this graph.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#Return a string description of this graph.