Skip to content
v2.273.0

WaitTime Class ​

Represents the Wait state which delays a state machine from continuing for a specified time.

Example ​

ts
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),
});

Methods ​

duration(duration: Duration): WaitTime // chainable@staticmethod def duration(duration: Duration) -> WaitTimepublic static WaitTime duration(Duration duration)public static WaitTime Duration(Duration duration)func Duration(Duration Duration) WaitTimestatic#
Wait a fixed amount of time.
seconds(seconds: string): WaitTime // chainable@staticmethod def seconds(seconds: str) -> WaitTimepublic static WaitTime seconds(String seconds)public static WaitTime Seconds(string seconds)func Seconds(Seconds *string) WaitTimestatic#
Wait for a number of seconds stored in the state object from string. This method can use JSONata expression.

If you want to use fixed value, we recommend using WaitTime.duration()

Example value: {% $waitSeconds %}

secondsPath(path: string): WaitTime // chainable@staticmethod def seconds_path(path: str) -> WaitTimepublic static WaitTime secondsPath(String path)public static WaitTime SecondsPath(string path)func SecondsPath(Path *string) WaitTimestatic#
Wait for a number of seconds stored in the state object.

Example value: $.waitSeconds

timestamp(timestamp: string): WaitTime // chainable@staticmethod def timestamp(timestamp: str) -> WaitTimepublic static WaitTime timestamp(String timestamp)public static WaitTime Timestamp(string timestamp)func Timestamp(Timestamp *string) WaitTimestatic#
Wait until the given ISO8601 timestamp. This method can use JSONata expression.

Example value: 2016-03-14T01:59:00Z

timestampPath(path: string): WaitTime // chainable@staticmethod def timestamp_path(path: str) -> WaitTimepublic static WaitTime timestampPath(String path)public static WaitTime TimestampPath(string path)func TimestampPath(Path *string) WaitTimestatic#
Wait until a timestamp found in the state object.

Example value: $.waitTimestamp