class Wait (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.StepFunctions.Wait |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#Wait |
Java | software.amazon.awscdk.services.stepfunctions.Wait |
Python | aws_cdk.aws_stepfunctions.Wait |
TypeScript (source) | aws-cdk-lib » aws_stepfunctions » Wait |
Implements
IConstruct
, IDependable
, IChainable
, INextable
Define a Wait state in the state machine.
A Wait state can be used to delay execution of the state machine for a while.
Example
const convertToSeconds = new tasks.EvaluateExpression(this, 'Convert to seconds', {
expression: '$.waitMilliseconds / 1000',
resultPath: '$.waitSeconds',
});
const createMessage = new tasks.EvaluateExpression(this, 'Create message', {
// Note: this is a string inside a string.
expression: '`Now waiting ${$.waitSeconds} seconds...`',
runtime: lambda.Runtime.NODEJS_LATEST,
resultPath: '$.message',
});
const publishMessage = new tasks.SnsPublish(this, 'Publish message', {
topic: new sns.Topic(this, 'cool-topic'),
message: sfn.TaskInput.fromJsonPathAt('$.message'),
resultPath: '$.sns',
});
const wait = new sfn.Wait(this, 'Wait', {
time: sfn.WaitTime.secondsPath('$.waitSeconds'),
});
new sfn.StateMachine(this, 'StateMachine', {
definition: convertToSeconds
.next(createMessage)
.next(publishMessage)
.next(wait),
});
Initializer
new Wait(scope: Construct, id: string, props: WaitProps)
Parameters
Construct Props
Name | Type | Description |
---|---|---|
time | Wait | Wait duration. |
comment? | string | An optional description for this state. |
state | string | Optional name for this state. |
time
Type:
Wait
Wait duration.
comment?
Type:
string
(optional, default: No comment)
An optional description for this state.
stateName?
Type:
string
(optional, default: The construct ID will be used as state name)
Optional name for this state.
Properties
Name | Type | Description |
---|---|---|
end | INextable [] | Continuable states of this Chainable. |
id | string | Descriptive identifier for this chainable. |
node | Node | The tree node. |
start | State | First state of this Chainable. |
state | string | Tokenized string that evaluates to the state's ID. |
endStates
Type:
INextable
[]
Continuable states of this Chainable.
id
Type:
string
Descriptive identifier for this chainable.
node
Type:
Node
The tree node.
startState
Type:
State
First state of this Chainable.
stateId
Type:
string
Tokenized string that evaluates to the state's ID.
Methods
Name | Description |
---|---|
add | Add a prefix to the stateId of this state. |
bind | Register this state as part of the given graph. |
next(next) | Continue normal execution with the given state. |
to | Return the Amazon States Language object for this state. |
to | Returns a string representation of this construct. |
addPrefix(x)
public addPrefix(x: string): void
Parameters
- x
string
Add a prefix to the stateId of this state.
bindToGraph(graph)
public bindToGraph(graph: StateGraph): void
Parameters
- graph
State
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.
next(next)
public next(next: IChainable): Chain
Parameters
- next
IChainable
Returns
Continue normal execution with the given state.
toStateJson()
public toStateJson(): json
Returns
json
Return the Amazon States Language object for this state.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.