cloudtools / cloudtools/troposphere

`FindInMap` should not allow `If` as a parameter

Open
#479 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.