Skip to content
v2.278.0

Condition Class ​

A Condition for use in a Choice state branch.

Example ​

ts
const map = new sfn.Map(this, 'Map State', {
  maxConcurrency: 1,
  itemsPath: sfn.JsonPath.stringAt('$.inputForMap'),
  itemSelector: {
    item: sfn.JsonPath.stringAt('$$.Map.Item.Value'),
  },
  resultPath: '$.mapOutput',
});

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
const choice = new sfn.Choice(this, 'Choice');
const condition1 = sfn.Condition.stringEquals('$.item.status', 'SUCCESS');
const step1 = new sfn.Pass(this, 'Step1');
const step2 = new sfn.Pass(this, 'Step2');
const finish = new sfn.Pass(this, 'Finish');

const definition = choice
    .when(condition1, step1)
    .otherwise(step2)
    .afterwards()
    .next(finish);

map.itemProcessor(definition);
python
map = sfn.Map(self, "Map State",
    max_concurrency=1,
    items_path=sfn.JsonPath.string_at("$.inputForMap"),
    item_selector={
        "item": sfn.JsonPath.string_at("$.Map.Item.Value")
    },
    result_path="$.mapOutput"
)

# The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
# Below example is with a Choice and Pass step
choice = sfn.Choice(self, "Choice")
condition1 = sfn.Condition.string_equals("$.item.status", "SUCCESS")
step1 = sfn.Pass(self, "Step1")
step2 = sfn.Pass(self, "Step2")
finish = sfn.Pass(self, "Finish")

definition = choice.when(condition1, step1).otherwise(step2).afterwards().next(finish)

map.item_processor(definition)
java
Map map = Map.Builder.create(this, "Map State")
        .maxConcurrency(1)
        .itemsPath(JsonPath.stringAt("$.inputForMap"))
        .itemSelector(Map.of(
                "item", JsonPath.stringAt("$.Map.Item.Value")))
        .resultPath("$.mapOutput")
        .build();

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
Choice choice = new Choice(this, "Choice");
Condition condition1 = Condition.stringEquals("$.item.status", "SUCCESS");
Pass step1 = new Pass(this, "Step1");
Pass step2 = new Pass(this, "Step2");
Pass finish = new Pass(this, "Finish");

Chain definition = choice.when(condition1, step1).otherwise(step2).afterwards().next(finish);

map.itemProcessor(definition);
csharp
// Install: dotnet add package Amazon.CDK.Lib
var map = new Map(this, "Map State", new MapProps {
    MaxConcurrency = 1,
    ItemsPath = JsonPath.StringAt("$.inputForMap"),
    ItemSelector = new Dictionary<string, object> {
        { "item", JsonPath.StringAt("$.Map.Item.Value") }
    },
    ResultPath = "$.mapOutput"
});

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
var choice = new Choice(this, "Choice");
var condition1 = Condition.StringEquals("$.item.status", "SUCCESS");
var step1 = new Pass(this, "Step1");
var step2 = new Pass(this, "Step2");
var finish = new Pass(this, "Finish");

var definition = choice.When(condition1, step1).Otherwise(step2).Afterwards().Next(finish);

map.ItemProcessor(definition);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
map := sfn.NewMap(this, jsii.String("Map State"), &MapProps{
	MaxConcurrency: jsii.Number(1),
	ItemsPath: sfn.JsonPath_StringAt(jsii.String("$.inputForMap")),
	ItemSelector: map[string]interface{}{
		"item": sfn.JsonPath_*StringAt(jsii.String("$.Map.Item.Value")),
	},
	ResultPath: jsii.String("$.mapOutput"),
})

// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
choice := sfn.NewChoice(this, jsii.String("Choice"))
condition1 := sfn.Condition_StringEquals(jsii.String("$.item.status"), jsii.String("SUCCESS"))
step1 := sfn.NewPass(this, jsii.String("Step1"))
step2 := sfn.NewPass(this, jsii.String("Step2"))
finish := sfn.NewPass(this, jsii.String("Finish"))

definition := choice.When(condition1, step1).Otherwise(step2).Afterwards().Next(finish)

map.ItemProcessor(definition)

Initializer ​

ts
new Condition()
python
Condition()
java
new Condition()
csharp
new Condition()
go
NewCondition()

Methods ​

and(...conditions: Condition[]): Condition // chainable@staticmethod def and(conditions: Condition) -> Conditionpublic static Condition and(Condition conditions)public static Condition And(Condition conditions)func And(Conditions Condition) Condition static #
Combine two or more conditions with a logical AND.
booleanEquals(variable: string, value: boolean): Condition // chainable@staticmethod def boolean_equals(variable: str, value: bool) -> Conditionpublic static Condition booleanEquals(String variable, Boolean value)public static Condition BooleanEquals(string variable, bool value)func BooleanEquals(Variable *string, Value *bool) Condition static #
Matches if a boolean field has the given value.
booleanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def boolean_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition booleanEqualsJsonPath(String variable, String value)public static Condition BooleanEqualsJsonPath(string variable, string value)func BooleanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a boolean field equals to a value at a given mapping path.
isBoolean(variable: string): Condition // chainable@staticmethod def is_boolean(variable: str) -> Conditionpublic static Condition isBoolean(String variable)public static Condition IsBoolean(string variable)func IsBoolean(Variable *string) Condition static #
Matches if variable is boolean.
isNotBoolean(variable: string): Condition // chainable@staticmethod def is_not_boolean(variable: str) -> Conditionpublic static Condition isNotBoolean(String variable)public static Condition IsNotBoolean(string variable)func IsNotBoolean(Variable *string) Condition static #
Matches if variable is not boolean.
isNotNull(variable: string): Condition // chainable@staticmethod def is_not_null(variable: str) -> Conditionpublic static Condition isNotNull(String variable)public static Condition IsNotNull(string variable)func IsNotNull(Variable *string) Condition static #
Matches if variable is not null.
isNotNumeric(variable: string): Condition // chainable@staticmethod def is_not_numeric(variable: str) -> Conditionpublic static Condition isNotNumeric(String variable)public static Condition IsNotNumeric(string variable)func IsNotNumeric(Variable *string) Condition static #
Matches if variable is not numeric.
isNotPresent(variable: string): Condition // chainable@staticmethod def is_not_present(variable: str) -> Conditionpublic static Condition isNotPresent(String variable)public static Condition IsNotPresent(string variable)func IsNotPresent(Variable *string) Condition static #
Matches if variable is not present.
isNotString(variable: string): Condition // chainable@staticmethod def is_not_string(variable: str) -> Conditionpublic static Condition isNotString(String variable)public static Condition IsNotString(string variable)func IsNotString(Variable *string) Condition static #
Matches if variable is not a string.
isNotTimestamp(variable: string): Condition // chainable@staticmethod def is_not_timestamp(variable: str) -> Conditionpublic static Condition isNotTimestamp(String variable)public static Condition IsNotTimestamp(string variable)func IsNotTimestamp(Variable *string) Condition static #
Matches if variable is not a timestamp.
isNull(variable: string): Condition // chainable@staticmethod def is_null(variable: str) -> Conditionpublic static Condition isNull(String variable)public static Condition IsNull(string variable)func IsNull(Variable *string) Condition static #
Matches if variable is Null.
isNumeric(variable: string): Condition // chainable@staticmethod def is_numeric(variable: str) -> Conditionpublic static Condition isNumeric(String variable)public static Condition IsNumeric(string variable)func IsNumeric(Variable *string) Condition static #
Matches if variable is numeric.
isPresent(variable: string): Condition // chainable@staticmethod def is_present(variable: str) -> Conditionpublic static Condition isPresent(String variable)public static Condition IsPresent(string variable)func IsPresent(Variable *string) Condition static #
Matches if variable is present.
isString(variable: string): Condition // chainable@staticmethod def is_string(variable: str) -> Conditionpublic static Condition isString(String variable)public static Condition IsString(string variable)func IsString(Variable *string) Condition static #
Matches if variable is a string.
isTimestamp(variable: string): Condition // chainable@staticmethod def is_timestamp(variable: str) -> Conditionpublic static Condition isTimestamp(String variable)public static Condition IsTimestamp(string variable)func IsTimestamp(Variable *string) Condition static #
Matches if variable is a timestamp.
jsonata(condition: string): Condition // chainable@staticmethod def jsonata(condition: str) -> Conditionpublic static Condition jsonata(String condition)public static Condition Jsonata(string condition)func Jsonata(Condition *string) Condition static #
JSONata expression condition.
not(condition: Condition): Condition // chainable@staticmethod def not(condition: Condition) -> Conditionpublic static Condition not(Condition condition)public static Condition Not(Condition condition)func Not(Condition Condition) Condition static #
Negate a condition.
numberEquals(variable: string, value: number): Condition // chainable@staticmethod def number_equals(variable: str, value: int | float) -> Conditionpublic static Condition numberEquals(String variable, Number value)public static Condition NumberEquals(string variable, double value)func NumberEquals(Variable *string, Value *float64) Condition static #
Matches if a numeric field has the given value.
numberEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def number_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition numberEqualsJsonPath(String variable, String value)public static Condition NumberEqualsJsonPath(string variable, string value)func NumberEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a numeric field has the value in a given mapping path.
numberGreaterThan(variable: string, value: number): Condition // chainable@staticmethod def number_greater_than(variable: str, value: int | float) -> Conditionpublic static Condition numberGreaterThan(String variable, Number value)public static Condition NumberGreaterThan(string variable, double value)func NumberGreaterThan(Variable *string, Value *float64) Condition static #
Matches if a numeric field is greater than the given value.
numberGreaterThanEquals(variable: string, value: number): Condition // chainable@staticmethod def number_greater_than_equals(variable: str, value: int | float) -> Conditionpublic static Condition numberGreaterThanEquals(String variable, Number value)public static Condition NumberGreaterThanEquals(string variable, double value)func NumberGreaterThanEquals(Variable *string, Value *float64) Condition static #
Matches if a numeric field is greater than or equal to the given value.
numberGreaterThanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def number_greater_than_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition numberGreaterThanEqualsJsonPath(String variable, String value)public static Condition NumberGreaterThanEqualsJsonPath(string variable, string value)func NumberGreaterThanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a numeric field is greater than or equal to the value at a given mapping path.
numberGreaterThanJsonPath(variable: string, value: string): Condition // chainable@staticmethod def number_greater_than_json_path(variable: str, value: str) -> Conditionpublic static Condition numberGreaterThanJsonPath(String variable, String value)public static Condition NumberGreaterThanJsonPath(string variable, string value)func NumberGreaterThanJsonPath(Variable *string, Value *string) Condition static #
Matches if a numeric field is greater than the value at a given mapping path.
numberLessThan(variable: string, value: number): Condition // chainable@staticmethod def number_less_than(variable: str, value: int | float) -> Conditionpublic static Condition numberLessThan(String variable, Number value)public static Condition NumberLessThan(string variable, double value)func NumberLessThan(Variable *string, Value *float64) Condition static #
Matches if a numeric field is less than the given value.
numberLessThanEquals(variable: string, value: number): Condition // chainable@staticmethod def number_less_than_equals(variable: str, value: int | float) -> Conditionpublic static Condition numberLessThanEquals(String variable, Number value)public static Condition NumberLessThanEquals(string variable, double value)func NumberLessThanEquals(Variable *string, Value *float64) Condition static #
Matches if a numeric field is less than or equal to the given value.
numberLessThanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def number_less_than_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition numberLessThanEqualsJsonPath(String variable, String value)public static Condition NumberLessThanEqualsJsonPath(string variable, string value)func NumberLessThanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a numeric field is less than or equal to the numeric value at given mapping path.
numberLessThanJsonPath(variable: string, value: string): Condition // chainable@staticmethod def number_less_than_json_path(variable: str, value: str) -> Conditionpublic static Condition numberLessThanJsonPath(String variable, String value)public static Condition NumberLessThanJsonPath(string variable, string value)func NumberLessThanJsonPath(Variable *string, Value *string) Condition static #
Matches if a numeric field is less than the value at the given mapping path.
or(...conditions: Condition[]): Condition // chainable@staticmethod def or(conditions: Condition) -> Conditionpublic static Condition or(Condition conditions)public static Condition Or(Condition conditions)func Or(Conditions Condition) Condition static #
Combine two or more conditions with a logical OR.
renderCondition(): anydef render_condition(self, ) -> Anypublic Object renderCondition()public object RenderCondition()func RenderCondition() interface{} #
Render Amazon States Language JSON for the condition.
stringEquals(variable: string, value: string): Condition // chainable@staticmethod def string_equals(variable: str, value: str) -> Conditionpublic static Condition stringEquals(String variable, String value)public static Condition StringEquals(string variable, string value)func StringEquals(Variable *string, Value *string) Condition static #
Matches if a string field has the given value.
stringEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def string_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition stringEqualsJsonPath(String variable, String value)public static Condition StringEqualsJsonPath(string variable, string value)func StringEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a string field equals to a value at a given mapping path.
stringGreaterThan(variable: string, value: string): Condition // chainable@staticmethod def string_greater_than(variable: str, value: str) -> Conditionpublic static Condition stringGreaterThan(String variable, String value)public static Condition StringGreaterThan(string variable, string value)func StringGreaterThan(Variable *string, Value *string) Condition static #
Matches if a string field sorts after a given value.
stringGreaterThanEquals(variable: string, value: string): Condition // chainable@staticmethod def string_greater_than_equals(variable: str, value: str) -> Conditionpublic static Condition stringGreaterThanEquals(String variable, String value)public static Condition StringGreaterThanEquals(string variable, string value)func StringGreaterThanEquals(Variable *string, Value *string) Condition static #
Matches if a string field sorts after or equal to a given value.
stringGreaterThanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def string_greater_than_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition stringGreaterThanEqualsJsonPath(String variable, String value)public static Condition StringGreaterThanEqualsJsonPath(string variable, string value)func StringGreaterThanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a string field sorts after or equal to value at a given mapping path.
stringGreaterThanJsonPath(variable: string, value: string): Condition // chainable@staticmethod def string_greater_than_json_path(variable: str, value: str) -> Conditionpublic static Condition stringGreaterThanJsonPath(String variable, String value)public static Condition StringGreaterThanJsonPath(string variable, string value)func StringGreaterThanJsonPath(Variable *string, Value *string) Condition static #
Matches if a string field sorts after a value at a given mapping path.
stringLessThan(variable: string, value: string): Condition // chainable@staticmethod def string_less_than(variable: str, value: str) -> Conditionpublic static Condition stringLessThan(String variable, String value)public static Condition StringLessThan(string variable, string value)func StringLessThan(Variable *string, Value *string) Condition static #
Matches if a string field sorts before a given value.
stringLessThanEquals(variable: string, value: string): Condition // chainable@staticmethod def string_less_than_equals(variable: str, value: str) -> Conditionpublic static Condition stringLessThanEquals(String variable, String value)public static Condition StringLessThanEquals(string variable, string value)func StringLessThanEquals(Variable *string, Value *string) Condition static #
Matches if a string field sorts equal to or before a given value.
stringLessThanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def string_less_than_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition stringLessThanEqualsJsonPath(String variable, String value)public static Condition StringLessThanEqualsJsonPath(string variable, string value)func StringLessThanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a string field sorts equal to or before a given mapping.
stringLessThanJsonPath(variable: string, value: string): Condition // chainable@staticmethod def string_less_than_json_path(variable: str, value: str) -> Conditionpublic static Condition stringLessThanJsonPath(String variable, String value)public static Condition StringLessThanJsonPath(string variable, string value)func StringLessThanJsonPath(Variable *string, Value *string) Condition static #
Matches if a string field sorts before a given value at a particular mapping.
stringMatches(variable: string, value: string): Condition // chainable@staticmethod def string_matches(variable: str, value: str) -> Conditionpublic static Condition stringMatches(String variable, String value)public static Condition StringMatches(string variable, string value)func StringMatches(Variable *string, Value *string) Condition static #
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: \\*.
timestampEquals(variable: string, value: string): Condition // chainable@staticmethod def timestamp_equals(variable: str, value: str) -> Conditionpublic static Condition timestampEquals(String variable, String value)public static Condition TimestampEquals(string variable, string value)func TimestampEquals(Variable *string, Value *string) Condition static #
Matches if a timestamp field is the same time as the given timestamp.
timestampEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def timestamp_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition timestampEqualsJsonPath(String variable, String value)public static Condition TimestampEqualsJsonPath(string variable, string value)func TimestampEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a timestamp field is the same time as the timestamp at a given mapping path.
timestampGreaterThan(variable: string, value: string): Condition // chainable@staticmethod def timestamp_greater_than(variable: str, value: str) -> Conditionpublic static Condition timestampGreaterThan(String variable, String value)public static Condition TimestampGreaterThan(string variable, string value)func TimestampGreaterThan(Variable *string, Value *string) Condition static #
Matches if a timestamp field is after the given timestamp.
timestampGreaterThanEquals(variable: string, value: string): Condition // chainable@staticmethod def timestamp_greater_than_equals(variable: str, value: str) -> Conditionpublic static Condition timestampGreaterThanEquals(String variable, String value)public static Condition TimestampGreaterThanEquals(string variable, string value)func TimestampGreaterThanEquals(Variable *string, Value *string) Condition static #
Matches if a timestamp field is after or equal to the given timestamp.
timestampGreaterThanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def timestamp_greater_than_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition timestampGreaterThanEqualsJsonPath(String variable, String value)public static Condition TimestampGreaterThanEqualsJsonPath(string variable, string value)func TimestampGreaterThanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a timestamp field is after or equal to the timestamp at a given mapping path.
timestampGreaterThanJsonPath(variable: string, value: string): Condition // chainable@staticmethod def timestamp_greater_than_json_path(variable: str, value: str) -> Conditionpublic static Condition timestampGreaterThanJsonPath(String variable, String value)public static Condition TimestampGreaterThanJsonPath(string variable, string value)func TimestampGreaterThanJsonPath(Variable *string, Value *string) Condition static #
Matches if a timestamp field is after the timestamp at a given mapping path.
timestampLessThan(variable: string, value: string): Condition // chainable@staticmethod def timestamp_less_than(variable: str, value: str) -> Conditionpublic static Condition timestampLessThan(String variable, String value)public static Condition TimestampLessThan(string variable, string value)func TimestampLessThan(Variable *string, Value *string) Condition static #
Matches if a timestamp field is before the given timestamp.
timestampLessThanEquals(variable: string, value: string): Condition // chainable@staticmethod def timestamp_less_than_equals(variable: str, value: str) -> Conditionpublic static Condition timestampLessThanEquals(String variable, String value)public static Condition TimestampLessThanEquals(string variable, string value)func TimestampLessThanEquals(Variable *string, Value *string) Condition static #
Matches if a timestamp field is before or equal to the given timestamp.
timestampLessThanEqualsJsonPath(variable: string, value: string): Condition // chainable@staticmethod def timestamp_less_than_equals_json_path(variable: str, value: str) -> Conditionpublic static Condition timestampLessThanEqualsJsonPath(String variable, String value)public static Condition TimestampLessThanEqualsJsonPath(string variable, string value)func TimestampLessThanEqualsJsonPath(Variable *string, Value *string) Condition static #
Matches if a timestamp field is before or equal to the timestamp at a given mapping path.
timestampLessThanJsonPath(variable: string, value: string): Condition // chainable@staticmethod def timestamp_less_than_json_path(variable: str, value: str) -> Conditionpublic static Condition timestampLessThanJsonPath(String variable, String value)public static Condition TimestampLessThanJsonPath(string variable, string value)func TimestampLessThanJsonPath(Variable *string, Value *string) Condition static #
Matches if a timestamp field is before the timestamp at a given mapping path.