cumuliform 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cumuliform/dsl/functions.rb +162 -80
- data/lib/cumuliform/template.rb +2 -2
- data/lib/cumuliform/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d5eb541e904fdde55ae6e920188a06577eab31766d5842d14cfacfa2780164
|
4
|
+
data.tar.gz: 2560adcb6fb377fb1a9365937a521d5e9f236ae144b4ddae9272b8c643e51afb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0023af24b418d860c8924209df4fe5656bc5781e2bf5a39b0346c1f016616b9437fbf6459be1c2eb01eb40a3beb1f0100bb286847a8f03f09f6b20aeae3d377e
|
7
|
+
data.tar.gz: 282616a93f674f9b0a39bd4995c48721c8bdd9a1147b59c9aa1892c7fd8e8689c227a9bfb7ce285eb5eb6b2e2335036912a020e70b5012fee51cd35c861ef869
|
@@ -4,8 +4,111 @@ module Cumuliform
|
|
4
4
|
module DSL
|
5
5
|
# DSL methods for working with CloudFormation Intrinsic and Ref functions
|
6
6
|
module Functions
|
7
|
+
# implements the intrinsic conditions functions
|
8
|
+
module ConditionFunctions
|
9
|
+
# Wraps Fn::And
|
10
|
+
#
|
11
|
+
# see
|
12
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86066
|
13
|
+
#
|
14
|
+
# Behaves as a logical AND operator for CloudFormation conditions.
|
15
|
+
# Arguments should be other conditions or things that will evaluate to
|
16
|
+
# <tt>true</tt> or <tt>false</tt>.
|
17
|
+
#
|
18
|
+
# @overload and(condition_1, ..., condition_n)
|
19
|
+
# @param condition_1 [Hash<boolean-returning ref, intrinsic function,
|
20
|
+
# or condition>] Condition / value to be ANDed
|
21
|
+
# @param condition_n [Hash<boolean-returning ref, intrinsic function,
|
22
|
+
# or condition>] Condition / value to be ANDed (min 2, max 10
|
23
|
+
# condition args)
|
24
|
+
# @return [Hash] the Fn::And object
|
25
|
+
def and(*conditions)
|
26
|
+
unless (2..10).cover?(conditions.length)
|
27
|
+
raise ArgumentError, "You must specify AT LEAST 2 and AT MOST 10 conditions"
|
28
|
+
end
|
29
|
+
{"Fn::And" => conditions}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Wraps Fn::Or
|
33
|
+
#
|
34
|
+
# see
|
35
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86490
|
36
|
+
#
|
37
|
+
# Behaves as a logical OR operator for CloudFormation conditions.
|
38
|
+
# Arguments should be other conditions or things that will evaluate to
|
39
|
+
# <tt>true</tt> or <tt>false</tt>.
|
40
|
+
#
|
41
|
+
# @overload or(condition_1, ..., condition_n)
|
42
|
+
# @param condition_1 [Hash<boolean-returning ref, intrinsic function,
|
43
|
+
# or condition>] Condition / value to be ORed
|
44
|
+
# @param condition_n [Hash<boolean-returning ref, intrinsic function,
|
45
|
+
# or condition>] Condition / value to be ORed (min 2, max 10
|
46
|
+
# condition args)
|
47
|
+
# @return [Hash] the Fn::Or object
|
48
|
+
def or(*conditions)
|
49
|
+
unless (2..10).cover?(conditions.length)
|
50
|
+
raise ArgumentError, "You must specify AT LEAST 2 and AT MOST 10 conditions"
|
51
|
+
end
|
52
|
+
{"Fn::Or" => conditions}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Wraps Fn::Not
|
56
|
+
#
|
57
|
+
# see
|
58
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86402
|
59
|
+
#
|
60
|
+
# Behaves as a logical NOT operator for CloudFormation conditions. The
|
61
|
+
# argument should be another condition or something that will evaluate
|
62
|
+
# to <tt>true</tt> or <tt>false</tt>
|
63
|
+
#
|
64
|
+
# @param condition [Hash<boolean-returning ref, intrinsic function, or
|
65
|
+
# condition>] Condition / value to be NOTed
|
66
|
+
# @return [Hash] the Fn::Not object
|
67
|
+
def not(condition)
|
68
|
+
{"Fn::Not" => [condition]}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Wraps Fn::Equals
|
72
|
+
#
|
73
|
+
# see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86148
|
74
|
+
#
|
75
|
+
# The arguments should be the literal values or refs you want to
|
76
|
+
# compare. Returns true or false when CloudFormation evaluates the
|
77
|
+
# template.
|
78
|
+
#
|
79
|
+
# @param value [String, Hash<value-returning ref>]
|
80
|
+
# @param other_value [String, Hash<value-returning ref>]
|
81
|
+
# @return [Hash] the Fn::Equals object
|
82
|
+
def equals(value, other_value)
|
83
|
+
{"Fn::Equals" => [value, other_value]}
|
84
|
+
end
|
85
|
+
|
86
|
+
# Wraps Fn::If
|
87
|
+
#
|
88
|
+
# see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86223
|
89
|
+
#
|
90
|
+
# CloudFormation evaluates the Condition referred to the logical ID in
|
91
|
+
# the <tt>condition</tt> arg and returns the <tt>true_value</tt> if
|
92
|
+
# <tt>true</tt> and <tt>false_value</tt> otherwise. <tt>condition</tt>
|
93
|
+
# cannot be an <tt>Fn::Ref</tt>, but you can use our <tt>xref()</tt>
|
94
|
+
# helper to ensure the logical ID is valid.
|
95
|
+
#
|
96
|
+
# @param condition[String] the Logical ID of the Condition to be
|
97
|
+
# checked
|
98
|
+
# @param true_value the value to be returned if <tt>condition</tt>
|
99
|
+
# evaluates true
|
100
|
+
# @param false_value the value to be returned if <tt>condition</tt>
|
101
|
+
# evaluates false
|
102
|
+
# @return [Hash] the Fn::If object
|
103
|
+
def if(condition, true_value, false_value)
|
104
|
+
{"Fn::If" => [condition, true_value, false_value]}
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
7
108
|
# implements wrappers for the intrinsic functions Fn::*
|
8
109
|
class IntrinsicFunctions
|
110
|
+
include ConditionFunctions
|
111
|
+
|
9
112
|
# @api private
|
10
113
|
attr_reader :template
|
11
114
|
|
@@ -86,42 +189,6 @@ module Cumuliform
|
|
86
189
|
{"Fn::GetAZs" => value}
|
87
190
|
end
|
88
191
|
|
89
|
-
# Wraps Fn::Equals
|
90
|
-
#
|
91
|
-
# see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86148
|
92
|
-
#
|
93
|
-
# The arguments should be the literal values or refs you want to
|
94
|
-
# compare. Returns true or false when CloudFormation evaluates the
|
95
|
-
# template.
|
96
|
-
#
|
97
|
-
# @param value [String, Hash<value-returning ref>]
|
98
|
-
# @param other_value [String, Hash<value-returning ref>]
|
99
|
-
# @return [Hash] the Fn::Equals object
|
100
|
-
def equals(value, other_value)
|
101
|
-
{"Fn::Equals" => [value, other_value]}
|
102
|
-
end
|
103
|
-
|
104
|
-
# Wraps Fn::If
|
105
|
-
#
|
106
|
-
# see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86223
|
107
|
-
#
|
108
|
-
# CloudFormation evaluates the Condition referred to the logical ID in
|
109
|
-
# the <tt>condition</tt> arg and returns the <tt>true_value</tt> if
|
110
|
-
# <tt>true</tt> and <tt>false_value</tt> otherwise. <tt>condition</tt>
|
111
|
-
# cannot be an <tt>Fn::Ref</tt>, but you can use our <tt>xref()</tt>
|
112
|
-
# helper to ensure the logical ID is valid.
|
113
|
-
#
|
114
|
-
# @param condition[String] the Logical ID of the Condition to be
|
115
|
-
# checked
|
116
|
-
# @param true_value the value to be returned if <tt>condition</tt>
|
117
|
-
# evaluates true
|
118
|
-
# @param false_value the value to be returned if <tt>condition</tt>
|
119
|
-
# evaluates false
|
120
|
-
# @return [Hash] the Fn::If object
|
121
|
-
def if(condition, true_value, false_value)
|
122
|
-
{"Fn::If" => [condition, true_value, false_value]}
|
123
|
-
end
|
124
|
-
|
125
192
|
# Wraps Fn::Select
|
126
193
|
#
|
127
194
|
# see
|
@@ -154,66 +221,81 @@ module Cumuliform
|
|
154
221
|
{"Fn::Select" => [index, array]}
|
155
222
|
end
|
156
223
|
|
157
|
-
# Wraps Fn::
|
224
|
+
# Wraps Fn::Cidr
|
158
225
|
#
|
159
226
|
# see
|
160
|
-
#
|
227
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-cidr.html
|
161
228
|
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
229
|
+
# @param ip_block [String] The user-specified CIDR address block to be
|
230
|
+
# split into smaller CIDR blocks. (e.g. "10.0.0.0/16")
|
231
|
+
# @param count [Integer] The number of CIDRs to generate. Valid range is
|
232
|
+
# between 1 and 256.
|
233
|
+
# @param cidr_bits [Integer] The number of subnet bits for the CIDR. For
|
234
|
+
# example, specifying a value "8" for this parameter will create a
|
235
|
+
# CIDR with a mask of "/24".
|
236
|
+
# @return [Hash] The Fn::Cidr object
|
237
|
+
def cidr(ip_block, count, cidr_bits)
|
238
|
+
{"Fn::Cidr" => [ip_block, count, cidr_bits]}
|
239
|
+
end
|
240
|
+
|
241
|
+
# Wraps Fn::ImportValue
|
165
242
|
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
|
173
|
-
|
174
|
-
unless (2..10).cover?(conditions.length)
|
175
|
-
raise ArgumentError, "You must specify AT LEAST 2 and AT MOST 10 conditions"
|
176
|
-
end
|
177
|
-
{"Fn::And" => conditions}
|
243
|
+
# see
|
244
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html
|
245
|
+
#
|
246
|
+
# @param shared_value_to_import [String] The stack output value to
|
247
|
+
# import
|
248
|
+
# @return [Hash] The Fn::ImportValue object
|
249
|
+
def import_value(shared_value_to_import)
|
250
|
+
{"Fn::ImportValue" => shared_value_to_import}
|
178
251
|
end
|
179
252
|
|
180
|
-
# Wraps Fn::
|
253
|
+
# Wraps Fn::Split
|
181
254
|
#
|
182
255
|
# see
|
183
|
-
#
|
256
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-split.html
|
184
257
|
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
258
|
+
# @param delimiter [String] The delimiter to split the source_string on
|
259
|
+
# @param source_string [String] The string to split
|
260
|
+
# @return [Hash] The Fn::Split object
|
261
|
+
def split(delimiter, source_string)
|
262
|
+
{"Fn::Split" => [delimiter, source_string]}
|
263
|
+
end
|
264
|
+
|
265
|
+
# Wraps Fn::Sub
|
188
266
|
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
267
|
+
# see
|
268
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html
|
269
|
+
#
|
270
|
+
# @param string [String] The string to substitute values into
|
271
|
+
# @param substitutions [Hash<String => String,Hash>] Optional hash of
|
272
|
+
# variable names and the value to substitute them for. The value can
|
273
|
+
# also be somethings like an Fn:Ref invocation.
|
274
|
+
# @return [Hash] The Fn::Sub object
|
275
|
+
def sub(string, substitutions = nil)
|
276
|
+
if substitutions.nil?
|
277
|
+
args = string
|
278
|
+
else
|
279
|
+
args = [string, substitutions]
|
199
280
|
end
|
200
|
-
{"Fn::
|
281
|
+
{"Fn::Sub" => args}
|
201
282
|
end
|
202
283
|
|
203
|
-
# Wraps Fn::
|
284
|
+
# Wraps Fn::Transform
|
204
285
|
#
|
205
286
|
# see
|
206
|
-
#
|
207
|
-
#
|
208
|
-
# Behaves as a logical NOT operator for CloudFormation conditions. The
|
209
|
-
# argument should be another condition or something that will evaluate
|
210
|
-
# to <tt>true</tt> or <tt>false</tt>
|
287
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-transform.html
|
211
288
|
#
|
212
|
-
# @param
|
213
|
-
#
|
214
|
-
# @return [Hash]
|
215
|
-
def
|
216
|
-
{
|
289
|
+
# @param macro_name [String] The name of the macro to call
|
290
|
+
# @param parameters [Hash] The hash of parameter names/values
|
291
|
+
# @return [Hash] The Fn::Transform object
|
292
|
+
def transform(macro_name, parameters = {})
|
293
|
+
{
|
294
|
+
"Fn::Transform" => {
|
295
|
+
"Name" => macro_name,
|
296
|
+
"Parameters" => parameters
|
297
|
+
}
|
298
|
+
}
|
217
299
|
end
|
218
300
|
end
|
219
301
|
|
data/lib/cumuliform/template.rb
CHANGED
@@ -8,8 +8,8 @@ require_relative 'output'
|
|
8
8
|
|
9
9
|
module Cumuliform
|
10
10
|
AWS_PSEUDO_PARAMS = %w{
|
11
|
-
|
12
|
-
|
11
|
+
AWS::AccountId AWS::NotificationARNs AWS::NoValue AWS::Partition
|
12
|
+
AWS::Region AWS::StackId AWS::StackName AWS::URLSuffix
|
13
13
|
}
|
14
14
|
TOP_LEVEL = %w{ Transform Description }
|
15
15
|
|
data/lib/cumuliform/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cumuliform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|