All Products
Search
Document Center

Resource Orchestration Service:Fn::Or

Last Updated:Mar 15, 2024

The built-in function Fn::Or represents the OR operator and must contain at least two conditions. If one of the conditions is evaluated to true, true is returned. If all the conditions are evaluated to false, false is returned.

Declaration

  • JSON

    {
      "Fn::Or": [
        "condition1",
        "condition2",
        ...
      ]
    }
  • YAML

    • Syntax for the full function name:

      Fn::Or:
        - condition1
        - condition2
        - ...
    • Syntax for the short form:

      !Or [condition1, condition2, ...]

Parameters

condition: the condition that you want to evaluate.

Return value

true or false.

Examples

In the following example, the Fn::Or function is used to define a condition in the Conditions section:

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  EnvType:
    Type: String
    Default: pre
Conditions:
  TestEqualsCond:
    !Equals
      - prod
      - !Ref EnvType
  TestOrCond:
    !Or
      - TestEqualsCond
      - !Equals
          - pre
          - !Ref EnvType
{
  "Parameters": {
    "EnvType": {
      "Default": "pre",
      "Type": "String"
    }
  },
  "Conditions": {
    "TestEqualsCond": {
      "Fn::Equals": [
        "prod",
        {"Ref": "EnvType"}
      ]
    },
    "TestAndCond": {
      "Fn::Or": [
        "TestEqualsCond",
        {
          "Fn::Equals": [
            "pre",
            {"Ref": "EnvType"}
          ]
        }
      ]
    }
  }
}

Supported functions