Posted On: Jan 11, 2023

Today, AWS CloudFormation updates the language extension transform to support default values and additional intrinsic functions in Fn::FindInMap. Customers can use these features to minimize the size of their CloudFormation templates, and improve their readability. The language transform extends CloudFormation template language with functions such as Fn::Length, Fn::JsonToString, and more. 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 AWS 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 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 AWS::KMS::Key resource type to enforce parameter value constraints such as KeyUsage property. You can achieve this in fewer lines 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 US East (Ohio and N. Virginia), US West (N. California and Oregon), Africa (Cape Town), Asia Pacific (Hong Kong, Jakarta, Mumbai, Osaka, Seoul, Singapore, Sydney, and Tokyo), Canada (Central), China (Beijing) operated by Sinnet, and China (Ningxia), operated by NWCD, Europe (Frankfurt, Ireland, London, Milan, Paris, and Stockholm), Middle East (Bahrain), South America (São Paulo), and AWS GovCloud (US) Regions. 

To learn more about language extension transform, refer to the CloudFormation documentation.

To learn template basics on how to use Parameters and Mappings, refer to our getting started guide.