module SparkleFormation::SparkleAttribute::Aws

AWS specific helper implementations

Public Instance Methods

_account_id()
Alias for: _cf_account_id
_and(*args)
Alias for: _cf_and
_cf_account_id() click to toggle source

Account ID generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 349
def _cf_account_id
  _ref("AWS::AccountId")
end
Also aliased as: _account_id, account_id!
_cf_and(*args) click to toggle source

Fn::And generator

@param args [Object] items to be AND'ed together @return [Hash] @note symbols will be processed and set as condition. strings

will be set as condition directly. procs will be evaluated
# 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
Also aliased as: _and, and!
_cf_attr(*args) click to toggle source

@overload _cf_attr(logical_id, attribute_name)

Fn::GetAtt generator
@param logical_id [String, Symbol] logical resource name
@param attribute_name [String, Symbol] name of desired resource attribute

@return [Hash]

# 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
Also aliased as: _cf_get_att, get_att!, attr!
_cf_base64(arg) click to toggle source

Fn::Base64 generator

@param arg [Object] argument to be encoded @return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 166
def _cf_base64(arg)
  {"Fn::Base64" => arg}
end
Also aliased as: base64!
_cf_cidr(ipblock, count, cidrbits) click to toggle source

CIDR generator

@param ipblock [String] CIDR address block @param count [Integer] Number of CIDRs to generate @param cidrbits [Integer] Number of subnet bits for the CIDR @return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 17
def _cf_cidr(ipblock, count, cidrbits)
  {"Fn::Cidr" => [ipblock, count, cidrbits]}
end
Also aliased as: _cidr, cidr!
_cf_condition(name) click to toggle source

Condition generator

@param name [String, Symbol] symbol will be processed @return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 209
def _cf_condition(name)
  __t_stringish(name)
  {"Condition" => __attribute_key(name)}
end
Also aliased as: _condition, condition!
_cf_depends_on(*args) click to toggle source

Resource dependency generator @overload _depends_on(resource_name)

@param resource_name [String, Symbol] logical resource name

@overload _depends_on(resource_names)

@param resource_names [Array<String, Symbol>] list of logical resource names

@overload _depends_on(*resource_names)

@param resource_names [Array<String, Symbol>] list of logical resource names

@return [Array<String>] @note this will directly modify the struct at its current context to inject depends on structure

# 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
Also aliased as: _depends_on, depends_on!
_cf_equals(v1, v2) click to toggle source

Fn::Equals generator

@param v1 [Object] @param v2 [Object] @return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 271
def _cf_equals(v1, v2)
  {"Fn::Equals" => _array(v1, v2)}
end
Also aliased as: _equals, equals!
_cf_find_in_map(thing, key, *suffix)
Alias for: _cf_map
_cf_get_att(*args)
Alias for: _cf_attr
_cf_get_azs(region = nil) click to toggle source

Fn::GetAZs generator

@param region [String, Symbol] String will pass through. Symbol will be converted to ref @return [Hash]

# 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
Also aliased as: get_azs!, azs!
_cf_if(cond, true_value, false_value) click to toggle source

Fn::If generator

@param cond [String, Symbol] symbol will be case processed @param true_value [Object] item to be used when true @param false_value [Object] item to be used when false @return [Hash]

# 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
Also aliased as: _if, if!
_cf_join(*args) click to toggle source

@overload _cf_join(*args, opts={})

Fn::Join generator
@param args [String, Hash] list of items to join
@param opts [Hash]
@option opts [Hash] :options options for join function
@option options [String] :delimiter value used for joining items. Defaults to ''

@return [Hash]

# 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
Also aliased as: _join, join!
_cf_map(thing, key, *suffix) click to toggle source

@overload _cf_map(map_name, top_level_key, second_level_key)

Fn::FindInMap generator
@param map_name [String, Symbol] name of map
@param top_level_key [String, Symbol, Hash] top level key name
@param second_level_key [String, Symbol, Hash] second level key name

@return [Hash]

# 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
Also aliased as: _cf_find_in_map, find_in_map!, map!
_cf_no_value() click to toggle source

No value generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 319
def _cf_no_value
  _ref("AWS::NoValue")
end
Also aliased as: _no_value, no_value!
_cf_not(arg) click to toggle source

Fn::Not generator

@param arg [Object] @return [Hash]

# 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
Also aliased as: _not, not!
_cf_notification_arns() click to toggle source

Notification ARNs generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 339
def _cf_notification_arns
  _ref("AWS::NotificationARNs")
end
_cf_on_condition(name) click to toggle source

Condition setter

@param name [String, Symbol] condition name @return [SparkleStruct] @note this is used to set a {“Condition” => “Name”} into the

current context, generally the top level of a resource
# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 223
def _cf_on_condition(name)
  _set(*_condition(name).to_a.flatten)
end
Also aliased as: _on_condition, on_condition!
_cf_or(*args) click to toggle source

Fn::Or generator

@param v1 [Object] @param v2 [Object] @return [Hash]

# 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
Also aliased as: _or, or!
_cf_partition() click to toggle source

Partition generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 443
def _cf_partition
  _ref("AWS::Partition")
end
Also aliased as: _partition, partition!
_cf_ref(thing) click to toggle source

Ref generator

@param thing [String, Symbol] reference name @return [Hash] @note Symbol value will force key processing

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 93
def _cf_ref(thing)
  __t_stringish(thing)
  {"Ref" => __attribute_key(thing)}
end
Also aliased as: _ref, ref!
_cf_region() click to toggle source

Region generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 329
def _cf_region
  _ref("AWS::Region")
end
Also aliased as: _region, region!
_cf_select(index, item) click to toggle source

Fn::Select generator

@param index [String, Symbol, Integer] Symbol will be converted to ref @param item [Object, Symbol] Symbol will be converted to ref @return [Hash]

# 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
Also aliased as: _select, select!
_cf_split(string, delimiter) click to toggle source

Split generator

@param string [String, Hash] string to split @param delimiter [String] delimiter to split string @return [Hash]

# 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
Also aliased as: _split, split!
_cf_stack_id() click to toggle source

Stack ID generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 359
def _cf_stack_id
  _ref("AWS::StackId")
end
Also aliased as: _stack_id, stack_id!
_cf_stack_name() click to toggle source

Stack name generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 369
def _cf_stack_name
  _ref("AWS::StackName")
end
Also aliased as: _stack_name, stack_name!
_cf_stack_output(stack_name, output_name) click to toggle source

Reference output value from nested stack

@param stack_name [String, Symbol] logical resource name of stack @param output_name [String, Symbol] stack output name

# 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
Also aliased as: _stack_output, stack_output!
_cf_sub(string, variables = nil) click to toggle source

Sub generator

@param string [String, Hash] string to apply substitution @param variables [Hash] key value mappings for substitution @return [Hash]

# 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
Also aliased as: _sub, sub!
_cf_tags(hash) click to toggle source

Set tags on a resource

@param hash [Hash] Key/value pair tags @return [SparkleStruct]

# 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
Also aliased as: _tags, tags!
_cf_transform(name, parameters) click to toggle source

Transform generator

@param name [String] name of transformation @param parameters [Hash] transformation parameters @return [Hash]

# 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
Also aliased as: _transform, transform!
_cf_url_suffix() click to toggle source

URL suffix generator

@return [Hash]

# File lib/sparkle_formation/sparkle_attribute/aws.rb, line 433
def _cf_url_suffix
  _ref("AWS::URLSuffix")
end
Also aliased as: _url_suffix, url_suffix!
_cf_value_import(thing) click to toggle source

ValueImport generator

@param thing [String, Symbol, Hash] value import @return [Hash]

# 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
Also aliased as: _import_value, import_value!
_cidr(ipblock, count, cidrbits)
Alias for: _cf_cidr
_condition(name)
Alias for: _cf_condition
_depends_on(*args)
Alias for: _cf_depends_on
_equals(v1, v2)
Alias for: _cf_equals
_if(cond, true_value, false_value)
Alias for: _cf_if
_import_value(thing)
Alias for: _cf_value_import
_join(*args)
Alias for: _cf_join
_no_value()
Alias for: _cf_no_value
_not(arg)
Alias for: _cf_not
_notification_arns()
_on_condition(name)
Alias for: _cf_on_condition
_or(*args)
Alias for: _cf_or
_partition()
Alias for: _cf_partition
_ref(thing)
Alias for: _cf_ref
_region()
Alias for: _cf_region
_select(index, item)
Alias for: _cf_select
_split(string, delimiter)
Alias for: _cf_split
_stack_id()
Alias for: _cf_stack_id
_stack_name()
Alias for: _cf_stack_name
_stack_output(stack_name, output_name)
Alias for: _cf_stack_output
_sub(string, variables = nil)
Alias for: _cf_sub
_tags(hash)
Alias for: _cf_tags
_transform(name, parameters)
Alias for: _cf_transform
_url_suffix()
Alias for: _cf_url_suffix
account_id!()
Alias for: _cf_account_id
and!(*args)
Alias for: _cf_and
attr!(*args)
Alias for: _cf_attr
azs!(region = nil)
Alias for: _cf_get_azs
base64!(arg)
Alias for: _cf_base64
cidr!(ipblock, count, cidrbits)
Alias for: _cf_cidr
condition!(name)
Alias for: _cf_condition
depends_on!(*args)
Alias for: _cf_depends_on
equals!(v1, v2)
Alias for: _cf_equals
find_in_map!(thing, key, *suffix)
Alias for: _cf_map
get_att!(*args)
Alias for: _cf_attr
get_azs!(region = nil)
Alias for: _cf_get_azs
if!(cond, true_value, false_value)
Alias for: _cf_if
import_value!(thing)
Alias for: _cf_value_import
join!(*args)
Alias for: _cf_join
map!(thing, key, *suffix)
Alias for: _cf_map
no_value!()
Alias for: _cf_no_value
not!(arg)
Alias for: _cf_not
notification_arns!()
on_condition!(name)
Alias for: _cf_on_condition
or!(*args)
Alias for: _cf_or
partition!()
Alias for: _cf_partition
ref!(thing)
Alias for: _cf_ref
region!()
Alias for: _cf_region
select!(index, item)
Alias for: _cf_select
split!(string, delimiter)
Alias for: _cf_split
stack_id!()
Alias for: _cf_stack_id
stack_name!()
Alias for: _cf_stack_name
stack_output!(stack_name, output_name)
Alias for: _cf_stack_output
sub!(string, variables = nil)
Alias for: _cf_sub
taggable?() click to toggle source

@return [TrueClass, FalseClass] resource can be tagged

# 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
tags!(hash)
Alias for: _cf_tags
transform!(name, parameters)
Alias for: _cf_transform
url_suffix!()
Alias for: _cf_url_suffix