Module: SparkleFormation::SparkleAttribute::Aws

Included in:
SparkleFormation::SparkleStruct::Aws
Defined in:
lib/sparkle_formation/sparkle_attribute/aws.rb

Overview

AWS specific helper implementations

Instance Method Summary collapse

Instance Method Details

#_cf_account_idHash Also known as: _account_id, account_id!

Account ID generator



349
350
351
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 349

def 
  _ref("AWS::AccountId")
end

#_cf_and(*args) ⇒ Hash Also known as: _and, and!

Note:

symbols will be processed and set as condition. strings will be set as condition directly. procs will be evaluated

Fn::And generator



249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 249

def _cf_and(*args)
  {
    "Fn::And" => _array(
      *args.map { |v|
      if v.is_a?(Symbol) || v.is_a?(String)
        _condition(v)
      else
        v
      end
    }
    ),
  }
end

#_cf_attr(logical_id, attribute_name) ⇒ Hash Also known as: _cf_get_att, get_att!, attr!

Fn::GetAtt generator



144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 144

def _cf_attr(*args)
  r_name = args.first
  args = args.slice(1, args.size)
  __t_stringish(r_name)
  args = args.map do |thing|
    if thing.is_a?(Symbol)
      _process_key(thing, :force)
    else
      thing
    end
  end
  {"Fn::GetAtt" => [__attribute_key(r_name), *args]}
end

#_cf_base64(arg) ⇒ Hash Also known as: base64!

Fn::Base64 generator



166
167
168
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 166

def _cf_base64(arg)
  {"Fn::Base64" => arg}
end

#_cf_cidr(ipblock, count, cidrbits) ⇒ Hash Also known as: _cidr, cidr!

CIDR generator



17
18
19
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 17

def _cf_cidr(ipblock, count, cidrbits)
  {"Fn::Cidr" => [ipblock, count, cidrbits]}
end

#_cf_condition(name) ⇒ Hash Also known as: _condition, condition!

Condition generator



209
210
211
212
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 209

def _cf_condition(name)
  __t_stringish(name)
  {"Condition" => __attribute_key(name)}
end

#_depends_on(resource_name) ⇒ Array<String> #_depends_on(resource_names) ⇒ Array<String> #_depends_on(*resource_names) ⇒ Array<String> Also known as: _depends_on, depends_on!

Note:

this will directly modify the struct at its current context to inject depends on structure

Resource dependency generator



385
386
387
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 385

def _cf_depends_on(*args)
  _set("DependsOn", [args].flatten.compact.map { |s| __attribute_key(s) })
end

#_cf_equals(v1, v2) ⇒ Hash Also known as: _equals, equals!

Fn::Equals generator



271
272
273
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 271

def _cf_equals(v1, v2)
  {"Fn::Equals" => _array(v1, v2)}
end

#_cf_get_azs(region = nil) ⇒ Hash Also known as: get_azs!, azs!

Fn::GetAZs generator



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 176

def _cf_get_azs(region = nil)
  region = case region
           when Symbol
             _cf_ref(region)
           when NilClass
             ""
           else
             region
           end
  {"Fn::GetAZs" => region}
end

#_cf_if(cond, true_value, false_value) ⇒ Hash Also known as: _if, if!

Fn::If generator



236
237
238
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 236

def _cf_if(cond, true_value, false_value)
  {"Fn::If" => _array(__attribute_key(cond), true_value, false_value)}
end

#_cf_join(*args, opts = {}) ⇒ Hash Also known as: _join, join!

Fn::Join generator

Options Hash (opts):

  • :options (Hash)

    options for join function



45
46
47
48
49
50
51
52
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 45

def _cf_join(*args)
  options = args.detect { |i| i.is_a?(Hash) && i[:options] } || {:options => {}}
  args.delete(options)
  unless args.size == 1
    args = [args]
  end
  {"Fn::Join" => [options[:options][:delimiter] || "", *args]}
end

#_cf_map(map_name, top_level_key, second_level_key) ⇒ Hash Also known as: _cf_find_in_map, find_in_map!, map!

Fn::FindInMap generator



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 119

def _cf_map(thing, key, *suffix)
  __t_stringish(thing)
  suffix = suffix.map do |item|
    if item.is_a?(Symbol)
      _process_key(item, :force)
    else
      item
    end
  end
  thing = __attribute_key(thing)
  if key.is_a?(Symbol)
    key = ref!(key)
  end
  {"Fn::FindInMap" => [thing, key, *suffix]}
end

#_cf_no_valueHash Also known as: _no_value, no_value!

No value generator



319
320
321
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 319

def _cf_no_value
  _ref("AWS::NoValue")
end

#_cf_not(arg) ⇒ Hash Also known as: _not, not!

Fn::Not generator



282
283
284
285
286
287
288
289
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 282

def _cf_not(arg)
  if arg.is_a?(String) || arg.is_a?(Symbol)
    arg = _condition(arg)
  else
    arg = _array(arg).first
  end
  {"Fn::Not" => [arg]}
end

#_cf_notification_arnsHash Also known as: _notification_arns, notification_arns!

Notification ARNs generator



339
340
341
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 339

def _cf_notification_arns
  _ref("AWS::NotificationARNs")
end

#_cf_on_condition(name) ⇒ SparkleStruct Also known as: _on_condition, on_condition!

Note:

this is used to set a => “Name” into the current context, generally the top level of a resource

Condition setter



223
224
225
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 223

def _cf_on_condition(name)
  _set(*_condition(name).to_a.flatten)
end

#_cf_or(*args) ⇒ Hash Also known as: _or, or!

Fn::Or generator



299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 299

def _cf_or(*args)
  {
    "Fn::Or" => _array(
      *args.map { |v|
      if v.is_a?(Symbol) || v.is_a?(String)
        _condition(v)
      else
        v
      end
    }
    ),
  }
end

#_cf_partitionHash Also known as: _partition, partition!

Partition generator



443
444
445
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 443

def _cf_partition
  _ref("AWS::Partition")
end

#_cf_ref(thing) ⇒ Hash Also known as: _ref, ref!

Note:

Symbol value will force key processing

Ref generator



93
94
95
96
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 93

def _cf_ref(thing)
  __t_stringish(thing)
  {"Ref" => __attribute_key(thing)}
end

#_cf_regionHash Also known as: _region, region!

Region generator



329
330
331
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 329

def _cf_region
  _ref("AWS::Region")
end

#_cf_select(index, item) ⇒ Hash Also known as: _select, select!

Fn::Select generator



196
197
198
199
200
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 196

def _cf_select(index, item)
  index = index.is_a?(Symbol) ? _cf_ref(index) : index
  item = _cf_ref(item) if item.is_a?(Symbol)
  {"Fn::Select" => [index, item]}
end

#_cf_split(string, delimiter) ⇒ Hash Also known as: _split, split!

Split generator



62
63
64
65
66
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 62

def _cf_split(string, delimiter)
  __t_stringish(string) unless string.is_a?(Hash)
  __t_stringish(delimiter) unless delimiter.is_a?(Hash)
  {"Fn::Split" => [delimiter, string]}
end

#_cf_stack_idHash Also known as: _stack_id, stack_id!

Stack ID generator



359
360
361
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 359

def _cf_stack_id
  _ref("AWS::StackId")
end

#_cf_stack_nameHash Also known as: _stack_name, stack_name!

Stack name generator



369
370
371
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 369

def _cf_stack_name
  _ref("AWS::StackName")
end

#_cf_stack_output(stack_name, output_name) ⇒ Object Also known as: _stack_output, stack_output!

Reference output value from nested stack



396
397
398
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 396

def _cf_stack_output(stack_name, output_name)
  _cf_attr(_process_key(stack_name), "Outputs.#{__attribute_key(output_name)}")
end

#_cf_sub(string, variables = nil) ⇒ Hash Also known as: _sub, sub!

Sub generator



76
77
78
79
80
81
82
83
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 76

def _cf_sub(string, variables = nil)
  if variables.nil?
    {"Fn::Sub" => string}
  else
    __t_hashish(variables)
    {"Fn::Sub" => [string, variables]}
  end
end

#_cf_tags(hash) ⇒ SparkleStruct Also known as: _tags, tags!

Set tags on a resource



419
420
421
422
423
424
425
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 419

def _cf_tags(hash)
  __t_hashish(hash)
  _set("Tags",
       hash.map { |k, v|
    {"Key" => __attribute_key(k), "Value" => v}
  })
end

#_cf_transform(name, parameters) ⇒ Hash Also known as: _transform, transform!

Transform generator



29
30
31
32
33
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 29

def _cf_transform(name, parameters)
  __t_stringish(name)
  __t_hashish(parameters)
  {"Fn::Transform" => {"Name" => name, "Parameters" => parameters}}
end

#_cf_url_suffixHash Also known as: _url_suffix, url_suffix!

URL suffix generator



433
434
435
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 433

def _cf_url_suffix
  _ref("AWS::URLSuffix")
end

#_cf_value_import(thing) ⇒ Hash Also known as: _import_value, import_value!

ValueImport generator



105
106
107
108
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 105

def _cf_value_import(thing)
  __t_stringish(thing) unless thing.is_a?(Hash)
  {"Fn::ImportValue" => __attribute_key(thing)}
end

#taggable?TrueClass, FalseClass



404
405
406
407
408
409
410
411
412
413
# File 'lib/sparkle_formation/sparkle_attribute/aws.rb', line 404

def taggable?
  if self[:type]
    resource = _self._provider._resources.lookup(self[:type].gsub("::", "_").downcase)
    resource && resource[:properties].include?("Tags")
  else
    if _parent
      _parent.taggable?
    end
  end
end