cfn-language-discussion
cfn-language-discussion copied to clipboard
FindInMap defaulting
Name of the resource
Other
Resource name
Mappings
Description
Mappings provide a great tool for configuration, easing the ability to reuse cloudformation templates across a variety of regions & partitions. However, there is a shortcoming with Mappings as they're only accessible via FindInMap which only works if you know the exact keys and if they're present. If I have a low-traction point of configurability, I need to declare every single permutation, even if it's identical in 99% of cases and if I add support for another domain, like a new region, I need to update the cfn mapping to add the new field. I would like to request either an additional function or an extension of FindInMap which allows defaulting behavior, so if a given tuple is not found in the Mapping, we get the default value instead of the template erroring due to an inability to get mapping.
An alternative solution which would support this use case would be function(s) that enable me to set up If conditions based on key existence in Mappings. So something like
!If
- !MappingPresent [Mapping, 'foo', 'bar']
- !FindInMap [Mapping, 'foo', 'bar']
- 'MyDefaultValue'
Other Details
This has been asked about several times on SO, but I see no historical requests for this feature, not sure if this hasn't been considered or if it has been discussed under a more abstract feature set
Related to aws-cloudformation/cfn-language-discussion#79
@ohshazbot Thank you very much for your feedback! Since this repository is focused on resource coverage, I'm transferring this issue over to a new GitHub repository dedicated to CloudFormation template language issues.
Hey @ohshazbot , we have a new RFC https://github.com/aws-cloudformation/cfn-language-discussion/pull/91 proposed to enhance Fn::FindInMap
, we invite you to have your input there as well.
Thank you for the feedback! We have launched this feature as part of the FindInMap enhancement:
Docs: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap-enhancements.html