All Products
Search
Document Center

Resource Orchestration Service:Fn::Not

Last Updated:Mar 15, 2024

The built-in function Fn::Not represents the NOT operator. If a condition is evaluated as false, true is returned. If a condition is evaluated as true, false is returned.

Declaration

  • JSON

    {
     "Fn::Not": "condition"
    }
  • YAML

    • Syntax for the full function name:

      Fn::Not: condition
    • Syntax for the short form:

      !Not condition

Parameters

condition: the condition that you want to evaluate.

Return value

true or false.

Examples

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

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

Supported functions