Good day. I made changes in the Condition section wherein
In aws cloudformation validate-template
the result is success.
But when I start using the create-stack via aws cloudformation create-stack
, then I get the error:
An error occurred (ValidationError) when calling the CreateStack operation: Template error: Fn::If cannot be preprocessed
This is the changes I made in the Condition section.
"Conditions": {
"Con1": {
"Fn::Not": [{
"Fn::Equals": [
{"Ref": "Environment"},
"abc"
]
}]
},
"Con2": {
"Fn::Not": [{
"Fn::Equals": [
{ "Fn::If":
[
"Con1",
{ "Fn::FindInMap" : [ "iamRoles", {"Ref": "HostnameAppId"}, "abc"] },
{ "Fn::FindInMap" : [ "iamRoles", {"Ref": "HostnameAppId"}, "xyz"] }
]
},
""]
}]
}
},
Sadly, Fn::If
is not supported in Conditions
. From docs:
Currently, AWS CloudFormation supports the Fn::If intrinsic function in the metadata attribute, update policy attribute, and property values in the Resources section and Outputs sections of a template.