cloudtools / cloudtools/troposphere

Allow Condition=None to mean "no condition"

Open
#391 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
4.9k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

Hello! I have a situation where I might want to include a condition on an output, so I have written this:

```
outputElasticIP = t.add_output(Output(
"outputElasticIP%s" % num_az,
Value=Ref(ElasticIP),
Condition=("ThirdAZ" if num_az == 3 else None)
))
```

Unfortunately, this results in (for `num_az = 1`):

```
"outputElasticIP1": {
"Condition": null,
"Value": {
"Ref": "ElasticIP1"
}
},
```

Without wrapping the entire output in a big if statement, with a Condition on one branch, and omitting the Condition on the other, is there a way to tersely supply an optional condition?

I realize I could do a dummy "True" condition everywhere, but that potentially adds hundreds of meaningless lines to my template.

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start at the Output entry point used by t.add_output and trace how its properties are serialized into the generated template. Verify the behavior with the shown conditional expression: a None condition should be omitted, while a named condition should remain, and the resulting output should contain Value as before.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.