class Condition
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.StepFunctions.Condition |
![]() | software.amazon.awscdk.services.stepfunctions.Condition |
![]() | aws_cdk.aws_stepfunctions.Condition |
![]() | @aws-cdk/aws-stepfunctions » Condition |
A Condition for use in a Choice state branch.
Example
import * as lambda from '@aws-cdk/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 `Payload`
outputPath: '$.Payload',
});
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: '$.Payload',
});
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
Name | Description |
---|---|
render | Render Amazon States Language JSON for the condition. |
static and(...conditions) | Combine two or more conditions with a logical AND. |
static boolean | Matches if a boolean field has the given value. |
static boolean | Matches if a boolean field equals to a value at a given mapping path. |
static is | Matches if variable is boolean. |
static is | Matches if variable is not boolean. |
static is | Matches if variable is not null. |
static is | Matches if variable is not numeric. |
static is | Matches if variable is not present. |
static is | Matches if variable is not a string. |
static is | Matches if variable is not a timestamp. |
static is | Matches if variable is Null. |
static is | Matches if variable is numeric. |
static is | Matches if variable is present. |
static is | Matches if variable is a string. |
static is | Matches if variable is a timestamp. |
static not(condition) | Negate a condition. |
static number | Matches if a numeric field has the given value. |
static number | Matches if a numeric field has the value in a given mapping path. |
static number | Matches if a numeric field is greater than the given value. |
static number | Matches if a numeric field is greater than or equal to the given value. |
static number | Matches if a numeric field is greater than or equal to the value at a given mapping path. |
static number | Matches if a numeric field is greater than the value at a given mapping path. |
static number | Matches if a numeric field is less than the given value. |
static number | Matches if a numeric field is less than or equal to the given value. |
static number | Matches if a numeric field is less than or equal to the numeric value at given mapping path. |
static number | 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 string | Matches if a string field has the given value. |
static string | Matches if a string field equals to a value at a given mapping path. |
static string | Matches if a string field sorts after a given value. |
static string | Matches if a string field sorts after or equal to a given value. |
static string | Matches if a string field sorts after or equal to value at a given mapping path. |
static string | Matches if a string field sorts after a value at a given mapping path. |
static string | Matches if a string field sorts before a given value. |
static string | Matches if a string field sorts equal to or before a given value. |
static string | Matches if a string field sorts equal to or before a given mapping. |
static string | Matches if a string field sorts before a given value at a particular mapping. |
static string | 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 timestamp | Matches if a timestamp field is the same time as the given timestamp. |
static timestamp | Matches if a timestamp field is the same time as the timestamp at a given mapping path. |
static timestamp | Matches if a timestamp field is after the given timestamp. |
static timestamp | Matches if a timestamp field is after or equal to the given timestamp. |
static timestamp | Matches if a timestamp field is after or equal to the timestamp at a given mapping path. |
static timestamp | Matches if a timestamp field is after the timestamp at a given mapping path. |
static timestamp | Matches if a timestamp field is before the given timestamp. |
static timestamp | Matches if a timestamp field is before or equal to the given timestamp. |
static timestamp | Matches if a timestamp field is before or equal to the timestamp at a given mapping path. |
static timestamp | 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
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
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
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
Matches if variable is boolean.
static isNotBoolean(variable)
public static isNotBoolean(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is not boolean.
static isNotNull(variable)
public static isNotNull(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is not null.
static isNotNumeric(variable)
public static isNotNumeric(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is not numeric.
static isNotPresent(variable)
public static isNotPresent(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is not present.
static isNotString(variable)
public static isNotString(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is not a string.
static isNotTimestamp(variable)
public static isNotTimestamp(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is not a timestamp.
static isNull(variable)
public static isNull(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is Null.
static isNumeric(variable)
public static isNumeric(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is numeric.
static isPresent(variable)
public static isPresent(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is present.
static isString(variable)
public static isString(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is a string.
static isTimestamp(variable)
public static isTimestamp(variable: string): Condition
Parameters
- variable
string
Returns
Matches if variable is a timestamp.
static not(condition)
public static not(condition: Condition): Condition
Parameters
- condition
Condition
Returns
Negate a condition.
static numberEquals(variable, value)
public static numberEquals(variable: string, value: number): Condition
Parameters
- variable
string
- value
number
Returns
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Matches if a timestamp field is before the timestamp at a given mapping path.