CustomState
- class aws_cdk.aws_stepfunctions.CustomState(scope, id, *, state_json)
Bases:
State
State defined by supplying Amazon States Language (ASL) in the state machine.
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_dynamodb as dynamodb # create a table table = dynamodb.Table(self, "montable", partition_key=dynamodb.Attribute( name="id", type=dynamodb.AttributeType.STRING ) ) final_status = sfn.Pass(self, "final step") # States language JSON to put an item into DynamoDB # snippet generated from https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-code-snippet.html#tutorial-code-snippet-1 state_json = { "Type": "Task", "Resource": "arn:aws:states:::dynamodb:putItem", "Parameters": { "TableName": table.table_name, "Item": { "id": { "S": "MyEntry" } } }, "ResultPath": null } # custom state which represents a task to insert data into DynamoDB custom = sfn.CustomState(self, "my custom task", state_json=state_json ) chain = sfn.Chain.start(custom).next(final_status) sm = sfn.StateMachine(self, "StateMachine", definition=chain, timeout=Duration.seconds(30) ) # don't forget permissions. You need to assign them table.grant_write_data(sm)
- Parameters:
scope (
Construct
) –id (
str
) –state_json (
Mapping
[str
,Any
]) – Amazon States Language (JSON-based) definition of the state.
Methods
- add_prefix(x)
Add a prefix to the stateId of this state.
- Parameters:
x (
str
) –- Return type:
None
- bind_to_graph(graph)
Register this state as part of the given graph.
Don’t call this. It will be called automatically when you work with states normally.
- Parameters:
graph (
StateGraph
) –- Return type:
None
- next(next)
Continue normal execution with the given state.
- Parameters:
next (
IChainable
) –- Return type:
- to_state_json()
Returns the Amazon States Language object for this state.
- Return type:
Mapping
[Any
,Any
]
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- end_states
Continuable states of this Chainable.
- id
Descriptive identifier for this chainable.
- node
The construct tree node associated with this construct.
- start_state
First state of this Chainable.
- state_id
Tokenized string that evaluates to the state’s ID.
Static Methods
- classmethod filter_nextables(states)
Return only the states that allow chaining from an array of states.
- classmethod find_reachable_end_states(start, *, include_error_handlers=None)
Find the set of end states states reachable through transitions from the given start state.
- classmethod find_reachable_states(start, *, include_error_handlers=None)
Find the set of states reachable through transitions from the given start state.
This does not retrieve states from within sub-graphs, such as states within a Parallel state’s branch.
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
- classmethod prefix_states(root, prefix)
Add a prefix to the stateId of all States found in a construct tree.
- Parameters:
root (
IConstruct
) –prefix (
str
) –
- Return type:
None