Fn::Not acts as the NOT operator. It returns true for a condition that evaluates to false, and false for a condition that evaluates to true.
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 to evaluate.
Return value
true or false.
Examples
Fn::Not can be used to define a condition only in the Conditions or Rules 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"}
]
}
}
}
}