Posted On: Jan 16, 2023
Today, Amazon CloudFormation updates the language extension transform to supports default values and additional intrinsic functions in Fn::FindInMap. Customers can use these features to minimize the length of their CloudFormation templates, and improve their readability. The language transform enables extensions to the CloudFormation template language with functions such as Fn::Length, Fn::JsonToString, etc. Customers can modularize their templates into groups with different attributes in Parameters and Mappings, and use Fn::FindInMap to refer to attributes of these groups. For example, you can use Fn::FindInMap for EC2 resource type with a Mappings section containing a single map, RegionMap, that associates AMIs with Amazon Web Services Regions to your EC2 instances. With these language enhancements, you can use intrinsic functions such as Fn::Split, Fn::Select, and others within Fn::FindInMap. Previously, Fn::FindInMap only supported Fn::FindInMap and Ref intrinsic functions. Additionally, you can define string or list type default values in Fn::FindInMap. To see the list of supported intrinsic functions and learn about Fn:FindInMap, refer to the user guide.
You can use Fn::Select and Fn::Split with Fn::FindInMap for KMS key resource type to enforce parameter value constraints such as KeyUsage property. You can achieve this in a single line of code, instead of declaring multiple conditions. Similarly, you can use default values in Fn::FindInMap to minimize the need for specifying all possible permutations of values in a mapping. For example, you do not have to create a mapping for every Region, and instead can use default values to specify not equal conditions. To see these and other examples, refer to our GitHub repo.
These features are available in Amazon Web Services China (Beijing) Region, operated by Sinnet, and Amazon Web Services China (Ningxia) Region, operated by NWCD.