aws-cdk-lib.aws_stepfunctions.Wait

class Wait (construct)

LanguageType name
.NETAmazon.CDK.AWS.StepFunctions.Wait
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#Wait
Javasoftware.amazon.awscdk.services.stepfunctions.Wait
Pythonaws_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_16_X,
  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

  • scope Construct
  • id string — Descriptive identifier for this chainable.
  • props WaitProps

Construct Props

NameTypeDescription
timeWaitTimeWait duration.
comment?stringAn optional description for this state.

time

Type: WaitTime

Wait duration.


comment?

Type: string (optional, default: No comment)

An optional description for this state.

Properties

NameTypeDescription
endStatesINextable[]Continuable states of this Chainable.
idstringDescriptive identifier for this chainable.
nodeNodeThe tree node.
startStateStateFirst state of this Chainable.
stateIdstringTokenized 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

NameDescription
addPrefix(x)Add a prefix to the stateId of this state.
bindToGraph(graph)Register this state as part of the given graph.
next(next)Continue normal execution with the given state.
toStateJson()Return the Amazon States Language object for this state.
toString()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 StateGraph

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

  • Chain

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.