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
You can use Fn::Not 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"}
]
}
}
}
}