全部產品
Search
文件中心

Resource Orchestration Service:Fn::Not

更新時間:Jun 19, 2024

調用內建函式Fn::Not代表NOT運算子。對計算為false的條件,返回true;對計算為true的條件,返回false。

函式宣告

  • JSON

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

    • 完整函數的文法。

      Fn::Not: condition
    • 縮寫形式。

      !Not condition

參數資訊

condition:計算為true或false的條件。

傳回值

true或false。

使用樣本

在Conditions中使用Fn::Not定義一個條件。

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"}
        ] 
      }
    }
  }
}

支援的函數