aws-cdk-lib.aws_stepfunctions.WaitTime

class WaitTime

LanguageType name
.NETAmazon.CDK.AWS.StepFunctions.WaitTime
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#WaitTime
Javasoftware.amazon.awscdk.services.stepfunctions.WaitTime
Pythonaws_cdk.aws_stepfunctions.WaitTime
TypeScript (source)aws-cdk-lib » aws_stepfunctions » WaitTime

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

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-wait-state.html

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

Methods

NameDescription
static duration(duration)Wait a fixed amount of time.
static secondsPath(path)Wait for a number of seconds stored in the state object.
static timestamp(timestamp)Wait until the given ISO8601 timestamp.
static timestampPath(path)Wait until a timestamp found in the state object.

static duration(duration)

public static duration(duration: Duration): WaitTime

Parameters

  • duration Duration

Returns

  • WaitTime

Wait a fixed amount of time.


static secondsPath(path)

public static secondsPath(path: string): WaitTime

Parameters

  • path string

Returns

  • WaitTime

Wait for a number of seconds stored in the state object.

Example value: $.waitSeconds


static timestamp(timestamp)

public static timestamp(timestamp: string): WaitTime

Parameters

  • timestamp string

Returns

  • WaitTime

Wait until the given ISO8601 timestamp.

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


static timestampPath(path)

public static timestampPath(path: string): WaitTime

Parameters

  • path string

Returns

  • WaitTime

Wait until a timestamp found in the state object.

Example value: $.waitTimestamp