すべてのプロダクト
Search
ドキュメントセンター

Resource Orchestration Service:Fn::Not

最終更新日:Jan 16, 2025

組み込み関数 Fn::Not は、NOT 演算子を表します。条件が false と評価された場合は、true が返されます。条件が true と評価された場合は、false が返されます。

宣言

  • JSON

    {
     "Fn::Not": "condition" // 条件
    }
  • YAML

    • 完全な関数名の構文:

      Fn::Not: condition // 条件
    • 短縮形の構文:

      !Not condition // 条件

パラメーター

condition: 評価する条件。

戻り値

true または false。

Fn::Not を使用して、Conditions セクションまたは Rules セクションのみで条件を定義できます。

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

サポートされている関数