You’ve most likely noticed, that Cloud Formation does not support any Boolean type for template Parameters (see AWS docs). You will get:

Template format error: Unrecognized parameter type: Boolean


But many of the resources have Boolean parameter, like AWS::RDS::DBInstance -> MultiAZ or its StorageEncrypted property.

Solution? Use following workaround:

  • a "yes" / "no" selection Parameter with String type (or really any two values which make sense to your use case / language), 
  • a Condition (converting String to a semi-Boolean) and 
  • in the resource's property, use the intrinsic function Fn:If to convert semi-Boolean result of the condition into real Boolean

Note that you cannot use the Condition directly as the property’s value, using e.g. “Ref” + its name - you’d get a validation error, even if you defined “DependsOn”: 

Unresolved resource dependencies [DbRdsMultiAZCondition] in the Resources block of the template
See following Gist showing the relevant parts of the template to implement the solution:

It's long and ugly, but it works :-)


This was originally posted on blogger here.


1 comments captured from original post on Blogger

pauldevine said on 2017-11-12

Thanks for this.