Skip to content

FindInMap defaulting #43

@ohshazbot

Description

@ohshazbot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions