The built-in function Fn::Equals compares two values to check whether they are equal. If the two values are equal, true is returned. If the two values are not equal, false is returned.
Declaration
JSON
{ "Fn::Equals": [ "value_1", "value_2" ] }
YAML
Syntax for the full function name:
Fn::Equals: - value_1 - value_2
Syntax for the short form:
!Equals [value_1, value_2]
Parameters
value
: the value that you want to compare.
Return value
true or false.
Examples
You can use Fn::Equals to define a condition only in the Conditions or Rules section.
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
EnvType:
Default: pre
Type: String
Conditions:
TestEqualsCond:
!Equals
- prod
- !Ref EnvType
{
"Parameters": {
"EnvType": {
"Default": "pre",
"Type": "String"
}
},
"Conditions": {
"TestEqualsCond": {
"Fn::Equals": [
"prod",
{"Ref": "EnvType"}
]
}
}
}