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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86477f5b5e5ff570e701ea108595ab37165e9c2c8c0b908d71a3376925a4d5f2
4
- data.tar.gz: 6f77929d740fe9aaecdc83b65d691458441d762688f658b0fd338560b5501f79
3
+ metadata.gz: b1d5eb541e904fdde55ae6e920188a06577eab31766d5842d14cfacfa2780164
4
+ data.tar.gz: 2560adcb6fb377fb1a9365937a521d5e9f236ae144b4ddae9272b8c643e51afb
5
5
  SHA512:
6
- metadata.gz: 6abcbc9530eddcf37006beaf07fa357ac21b51bc325195825ed9b04b71ee2fadf2a305fea65458b7595a4e522bf44ea751878a1965e8c7f51ce6c7f5dfd05dc8
7
- data.tar.gz: ea4cd0da1e21c9a86514ec9d5f4ab7c754240f32bdde7567c8576ebad5786d9d9adbb3cc6bf6bcddae68960145175a8a16841097bf6d3e48d0c03654a7955b2d
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::And
224
+ # Wraps Fn::Cidr
158
225
  #
159
226
  # see
160
- # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86066
227
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-cidr.html
161
228
  #
162
- # Behaves as a logical AND operator for CloudFormation conditions.
163
- # Arguments should be other conditions or things that will evaluate to
164
- # <tt>true</tt> or <tt>false</tt>.
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
- # @overload and(condition_1, ..., condition_n)
167
- # @param condition_1 [Hash<boolean-returning ref, intrinsic function,
168
- # or condition>] Condition / value to be ANDed
169
- # @param condition_n [Hash<boolean-returning ref, intrinsic function,
170
- # or condition>] Condition / value to be ANDed (min 2, max 10
171
- # condition args)
172
- # @return [Hash] the Fn::And object
173
- def and(*conditions)
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::Or
253
+ # Wraps Fn::Split
181
254
  #
182
255
  # see
183
- # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86490
256
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-split.html
184
257
  #
185
- # Behaves as a logical OR operator for CloudFormation conditions.
186
- # Arguments should be other conditions or things that will evaluate to
187
- # <tt>true</tt> or <tt>false</tt>.
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
- # @overload or(condition_1, ..., condition_n)
190
- # @param condition_1 [Hash<boolean-returning ref, intrinsic function,
191
- # or condition>] Condition / value to be ORed
192
- # @param condition_n [Hash<boolean-returning ref, intrinsic function,
193
- # or condition>] Condition / value to be ORed (min 2, max 10
194
- # condition args)
195
- # @return [Hash] the Fn::Or object
196
- def or(*conditions)
197
- unless (2..10).cover?(conditions.length)
198
- raise ArgumentError, "You must specify AT LEAST 2 and AT MOST 10 conditions"
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::Or" => conditions}
281
+ {"Fn::Sub" => args}
201
282
  end
202
283
 
203
- # Wraps Fn::Not
284
+ # Wraps Fn::Transform
204
285
  #
205
286
  # see
206
- # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#d0e86402
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 condition [Hash<boolean-returning ref, intrinsic function, or
213
- # condition>] Condition / value to be NOTed
214
- # @return [Hash] the Fn::Not object
215
- def not(condition)
216
- {"Fn::Not" => [condition]}
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
 
@@ -8,8 +8,8 @@ require_relative 'output'
8
8
 
9
9
  module Cumuliform
10
10
  AWS_PSEUDO_PARAMS = %w{
11
- AWS::AccountId AWS::NotificationARNs AWS::NoValue
12
- AWS::Region AWS::StackId AWS::StackName
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
 
@@ -1,3 +1,3 @@
1
1
  module Cumuliform
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake