cloudtools / cloudtools/troposphere
`FindInMap` should not allow `If` as a parameter
- Dominant language
- Python
- Stars
- 4.9k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
Given something like:
``` python
FindInMap(
"MyMap",
Ref("SomeParameter"),
If('SomeConditional', 'key1', 'key2'),
),
```
When uploading this template to CloudFormation, it results in the following error:
> Template validation error: Template error: every Fn::FindInMap object requires three parameters, the map name, map key and the attribute for return value
In order to be processed successfully, it must be written as:
``` python
If(
'SomeConditional',
FindInMap(
"MyMap",
Ref("SomeParameter"),
'key1',
),
FindInMap(
"MyMap",
Ref("SomeParameter"),
'key2',
),
),
```
This is confirmed by the CF documentation at http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap.html under "Supported Functions", which states that the only functions that can be used inside of `FindInMap` are `Ref` or another `FindInMap`.
It would be nice if Troposphere could provide this "compile time" validation like it does for so many other things.
Contributor guide
Assessment
This issue has not been assessed yet.