|
|
@ -190,6 +190,55 @@ Will result in: |
|
|
|
MyFavouriteNumber: 1 |
|
|
|
``` |
|
|
|
|
|
|
|
#### !if |
|
|
|
|
|
|
|
Conditionally include portions of the document. |
|
|
|
|
|
|
|
Expects to receive an array where the first element is a condition, the second is |
|
|
|
the value if the condition is true, and the third is the value if the condition |
|
|
|
is false. |
|
|
|
|
|
|
|
Expressions use postfix notation because this is a play project right now and |
|
|
|
it's both fun and easy to implement and my HP calculator demanded it. Bright side, |
|
|
|
you never have to worry about operator precedence! |
|
|
|
|
|
|
|
Example: |
|
|
|
|
|
|
|
``` |
|
|
|
cnfpp: |
|
|
|
variables: |
|
|
|
LoadBalancerType: internal |
|
|
|
|
|
|
|
Resources: |
|
|
|
MyLoadBalancer: |
|
|
|
Subnet: !if |
|
|
|
- LoadBalancerType "internal" eq |
|
|
|
- subnet-1234 |
|
|
|
- subnet-6789 |
|
|
|
``` |
|
|
|
|
|
|
|
The true/false values can include maps/arrays/any other valid YAML. |
|
|
|
|
|
|
|
#### Expressions |
|
|
|
|
|
|
|
Expressions are composed of space separated values and operators. Value components |
|
|
|
are: |
|
|
|
|
|
|
|
* Numeric Literals: Any integer or float value. |
|
|
|
* String Literals: Any value enclosed in double quotes (`"`). A backslash can be |
|
|
|
used to quote/escape literal quotes within the string. |
|
|
|
* Variables: Any non-quoted string consisting of letters and numbers (no leading |
|
|
|
digit) is interpreted as a reference to one of the variables. |
|
|
|
* Operator: Currently supported comparison/logical operators are: |
|
|
|
- eq: equal |
|
|
|
- neq: not equal |
|
|
|
- gt: greater than |
|
|
|
- gte: greater than or equal |
|
|
|
- lt: less than |
|
|
|
- lte: less than or equal |
|
|
|
- and: boolean and |
|
|
|
- or: boolean or |
|
|
|
|
|
|
|
## Usage |
|
|
|
|
|
|
|
### Running |
|
|
@ -208,12 +257,5 @@ Note: Building is not required to run. |
|
|
|
## TODO |
|
|
|
|
|
|
|
* Provision rendered templates directly to CloudFormation |
|
|
|
* Maybe look at implementing an actual dependency graph to make stuff like "multiple inheritance" a little cleaner. |
|
|
|
E.g., if a single app stack pulls in multiple resources which all depend on `base.yaml`, don't reprocess base.yaml a |
|
|
|
bunch of times but instead just realize that's the root and process it once. |
|
|
|
* Add flow control: `!if`, `!foreach`, etc |
|
|
|
* Extend variables to support arrays/maps. Probably write a helper or add a toArray on Node since we're having to |
|
|
|
convert to/from dom nodes and arrays/maps all over the place. |
|
|
|
* Build an expression parser. Just to make everyone's life difficult, because it's fun and this is a toy project, and |
|
|
|
also to avoid having to care about operator precedence let's do it all postfix? My HP50G would be proud. |
|
|
|
* Some sort of macro system would be good. |
|
|
|