cloudtools / cloudtools/troposphere
Allow Condition=None to mean "no condition"
- 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
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