aws-cdk-lib.aws_stepfunctions.Condition

class Condition

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

A Condition for use in a Choice state branch.

Example

import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const submitLambda: lambda.Function;
declare const getStatusLambda: lambda.Function;

const submitJob = new tasks.LambdaInvoke(this, 'Submit Job', {
  lambdaFunction: submitLambda,
  // Lambda's result is in the attribute `guid`
  outputPath: '$.guid',
});

const waitX = new sfn.Wait(this, 'Wait X Seconds', {
  time: sfn.WaitTime.secondsPath('$.waitSeconds'),
});

const getStatus = new tasks.LambdaInvoke(this, 'Get Job Status', {
  lambdaFunction: getStatusLambda,
  // Pass just the field named "guid" into the Lambda, put the
  // Lambda's result in a field called "status" in the response
  inputPath: '$.guid',
  outputPath: '$.status',
});

const jobFailed = new sfn.Fail(this, 'Job Failed', {
  cause: 'AWS Batch Job Failed',
  error: 'DescribeJob returned FAILED',
});

const finalStatus = new tasks.LambdaInvoke(this, 'Get Final Job Status', {
  lambdaFunction: getStatusLambda,
  // Use "guid" field as input
  inputPath: '$.guid',
  outputPath: '$.Payload',
});

const definition = submitJob
  .next(waitX)
  .next(getStatus)
  .next(new sfn.Choice(this, 'Job Complete?')
    // Look at the "status" field
    .when(sfn.Condition.stringEquals('$.status', 'FAILED'), jobFailed)
    .when(sfn.Condition.stringEquals('$.status', 'SUCCEEDED'), finalStatus)
    .otherwise(waitX));

new sfn.StateMachine(this, 'StateMachine', {
  definition,
  timeout: Duration.minutes(5),
});

Initializer

new Condition()

Methods

NameDescription
renderCondition()Render Amazon States Language JSON for the condition.
static and(...conditions)Combine two or more conditions with a logical AND.
static booleanEquals(variable, value)Matches if a boolean field has the given value.
static booleanEqualsJsonPath(variable, value)Matches if a boolean field equals to a value at a given mapping path.
static isBoolean(variable)Matches if variable is boolean.
static isNotBoolean(variable)Matches if variable is not boolean.
static isNotNull(variable)Matches if variable is not null.
static isNotNumeric(variable)Matches if variable is not numeric.
static isNotPresent(variable)Matches if variable is not present.
static isNotString(variable)Matches if variable is not a string.
static isNotTimestamp(variable)Matches if variable is not a timestamp.
static isNull(variable)Matches if variable is Null.
static isNumeric(variable)Matches if variable is numeric.
static isPresent(variable)Matches if variable is present.
static isString(variable)Matches if variable is a string.
static isTimestamp(variable)Matches if variable is a timestamp.
static not(condition)Negate a condition.
static numberEquals(variable, value)Matches if a numeric field has the given value.
static numberEqualsJsonPath(variable, value)Matches if a numeric field has the value in a given mapping path.
static numberGreaterThan(variable, value)Matches if a numeric field is greater than the given value.
static numberGreaterThanEquals(variable, value)Matches if a numeric field is greater than or equal to the given value.
static numberGreaterThanEqualsJsonPath(variable, value)Matches if a numeric field is greater than or equal to the value at a given mapping path.
static numberGreaterThanJsonPath(variable, value)Matches if a numeric field is greater than the value at a given mapping path.
static numberLessThan(variable, value)Matches if a numeric field is less than the given value.
static numberLessThanEquals(variable, value)Matches if a numeric field is less than or equal to the given value.
static numberLessThanEqualsJsonPath(variable, value)Matches if a numeric field is less than or equal to the numeric value at given mapping path.
static numberLessThanJsonPath(variable, value)Matches if a numeric field is less than the value at the given mapping path.
static or(...conditions)Combine two or more conditions with a logical OR.
static stringEquals(variable, value)Matches if a string field has the given value.
static stringEqualsJsonPath(variable, value)Matches if a string field equals to a value at a given mapping path.
static stringGreaterThan(variable, value)Matches if a string field sorts after a given value.
static stringGreaterThanEquals(variable, value)Matches if a string field sorts after or equal to a given value.
static stringGreaterThanEqualsJsonPath(variable, value)Matches if a string field sorts after or equal to value at a given mapping path.
static stringGreaterThanJsonPath(variable, value)Matches if a string field sorts after a value at a given mapping path.
static stringLessThan(variable, value)Matches if a string field sorts before a given value.
static stringLessThanEquals(variable, value)Matches if a string field sorts equal to or before a given value.
static stringLessThanEqualsJsonPath(variable, value)Matches if a string field sorts equal to or before a given mapping.
static stringLessThanJsonPath(variable, value)Matches if a string field sorts before a given value at a particular mapping.
static stringMatches(variable, value)Matches if a field matches a string pattern that can contain a wild card () e.g: log-.txt or LATEST. No other characters other than "" have any special meaning - * can be escaped: \.
static timestampEquals(variable, value)Matches if a timestamp field is the same time as the given timestamp.
static timestampEqualsJsonPath(variable, value)Matches if a timestamp field is the same time as the timestamp at a given mapping path.
static timestampGreaterThan(variable, value)Matches if a timestamp field is after the given timestamp.
static timestampGreaterThanEquals(variable, value)Matches if a timestamp field is after or equal to the given timestamp.
static timestampGreaterThanEqualsJsonPath(variable, value)Matches if a timestamp field is after or equal to the timestamp at a given mapping path.
static timestampGreaterThanJsonPath(variable, value)Matches if a timestamp field is after the timestamp at a given mapping path.
static timestampLessThan(variable, value)Matches if a timestamp field is before the given timestamp.
static timestampLessThanEquals(variable, value)Matches if a timestamp field is before or equal to the given timestamp.
static timestampLessThanEqualsJsonPath(variable, value)Matches if a timestamp field is before or equal to the timestamp at a given mapping path.
static timestampLessThanJsonPath(variable, value)Matches if a timestamp field is before the timestamp at a given mapping path.

renderCondition()

public renderCondition(): any

Returns

  • any

Render Amazon States Language JSON for the condition.


static and(...conditions)

public static and(...conditions: Condition[]): Condition

Parameters

  • conditions Condition

Returns

  • Condition

Combine two or more conditions with a logical AND.


static booleanEquals(variable, value)

public static booleanEquals(variable: string, value: boolean): Condition

Parameters

  • variable string
  • value boolean

Returns

  • Condition

Matches if a boolean field has the given value.


static booleanEqualsJsonPath(variable, value)

public static booleanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a boolean field equals to a value at a given mapping path.


static isBoolean(variable)

public static isBoolean(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is boolean.


static isNotBoolean(variable)

public static isNotBoolean(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is not boolean.


static isNotNull(variable)

public static isNotNull(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is not null.


static isNotNumeric(variable)

public static isNotNumeric(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is not numeric.


static isNotPresent(variable)

public static isNotPresent(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is not present.


static isNotString(variable)

public static isNotString(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is not a string.


static isNotTimestamp(variable)

public static isNotTimestamp(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is not a timestamp.


static isNull(variable)

public static isNull(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is Null.


static isNumeric(variable)

public static isNumeric(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is numeric.


static isPresent(variable)

public static isPresent(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is present.


static isString(variable)

public static isString(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is a string.


static isTimestamp(variable)

public static isTimestamp(variable: string): Condition

Parameters

  • variable string

Returns

  • Condition

Matches if variable is a timestamp.


static not(condition)

public static not(condition: Condition): Condition

Parameters

  • condition Condition

Returns

  • Condition

Negate a condition.


static numberEquals(variable, value)

public static numberEquals(variable: string, value: number): Condition

Parameters

  • variable string
  • value number

Returns

  • Condition

Matches if a numeric field has the given value.


static numberEqualsJsonPath(variable, value)

public static numberEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a numeric field has the value in a given mapping path.


static numberGreaterThan(variable, value)

public static numberGreaterThan(variable: string, value: number): Condition

Parameters

  • variable string
  • value number

Returns

  • Condition

Matches if a numeric field is greater than the given value.


static numberGreaterThanEquals(variable, value)

public static numberGreaterThanEquals(variable: string, value: number): Condition

Parameters

  • variable string
  • value number

Returns

  • Condition

Matches if a numeric field is greater than or equal to the given value.


static numberGreaterThanEqualsJsonPath(variable, value)

public static numberGreaterThanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a numeric field is greater than or equal to the value at a given mapping path.


static numberGreaterThanJsonPath(variable, value)

public static numberGreaterThanJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a numeric field is greater than the value at a given mapping path.


static numberLessThan(variable, value)

public static numberLessThan(variable: string, value: number): Condition

Parameters

  • variable string
  • value number

Returns

  • Condition

Matches if a numeric field is less than the given value.


static numberLessThanEquals(variable, value)

public static numberLessThanEquals(variable: string, value: number): Condition

Parameters

  • variable string
  • value number

Returns

  • Condition

Matches if a numeric field is less than or equal to the given value.


static numberLessThanEqualsJsonPath(variable, value)

public static numberLessThanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a numeric field is less than or equal to the numeric value at given mapping path.


static numberLessThanJsonPath(variable, value)

public static numberLessThanJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a numeric field is less than the value at the given mapping path.


static or(...conditions)

public static or(...conditions: Condition[]): Condition

Parameters

  • conditions Condition

Returns

  • Condition

Combine two or more conditions with a logical OR.


static stringEquals(variable, value)

public static stringEquals(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field has the given value.


static stringEqualsJsonPath(variable, value)

public static stringEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field equals to a value at a given mapping path.


static stringGreaterThan(variable, value)

public static stringGreaterThan(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts after a given value.


static stringGreaterThanEquals(variable, value)

public static stringGreaterThanEquals(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts after or equal to a given value.


static stringGreaterThanEqualsJsonPath(variable, value)

public static stringGreaterThanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts after or equal to value at a given mapping path.


static stringGreaterThanJsonPath(variable, value)

public static stringGreaterThanJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts after a value at a given mapping path.


static stringLessThan(variable, value)

public static stringLessThan(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts before a given value.


static stringLessThanEquals(variable, value)

public static stringLessThanEquals(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts equal to or before a given value.


static stringLessThanEqualsJsonPath(variable, value)

public static stringLessThanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts equal to or before a given mapping.


static stringLessThanJsonPath(variable, value)

public static stringLessThanJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a string field sorts before a given value at a particular mapping.


static stringMatches(variable, value)

public static stringMatches(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a field matches a string pattern that can contain a wild card () e.g: log-.txt or LATEST. No other characters other than "" have any special meaning - * can be escaped: \.


static timestampEquals(variable, value)

public static timestampEquals(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is the same time as the given timestamp.


static timestampEqualsJsonPath(variable, value)

public static timestampEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is the same time as the timestamp at a given mapping path.


static timestampGreaterThan(variable, value)

public static timestampGreaterThan(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is after the given timestamp.


static timestampGreaterThanEquals(variable, value)

public static timestampGreaterThanEquals(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is after or equal to the given timestamp.


static timestampGreaterThanEqualsJsonPath(variable, value)

public static timestampGreaterThanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is after or equal to the timestamp at a given mapping path.


static timestampGreaterThanJsonPath(variable, value)

public static timestampGreaterThanJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is after the timestamp at a given mapping path.


static timestampLessThan(variable, value)

public static timestampLessThan(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is before the given timestamp.


static timestampLessThanEquals(variable, value)

public static timestampLessThanEquals(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is before or equal to the given timestamp.


static timestampLessThanEqualsJsonPath(variable, value)

public static timestampLessThanEqualsJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is before or equal to the timestamp at a given mapping path.


static timestampLessThanJsonPath(variable, value)

public static timestampLessThanJsonPath(variable: string, value: string): Condition

Parameters

  • variable string
  • value string

Returns

  • Condition

Matches if a timestamp field is before the timestamp at a given mapping path.