Method: Cfer::Core::Resource#tag

Defined in:
lib/cfer/core/resource.rb

#tag(k, v, **options) ⇒ Object

Sets a tag on this resource. The resource must support the CloudFormation Tags property.

Parameters:

  • k (String)

    The name of the tag to set

  • v (String)

    The value for this tag

  • options (Hash)

    An arbitrary set of additional properties to be added to this tag, for example PropagateOnLaunch on AWS::AutoScaling::AutoScalingGroup



42
43
44
45
46
# File 'lib/cfer/core/resource.rb', line 42

def tag(k, v, **options)
  self[:Properties][:Tags] ||= []
  self[:Properties][:Tags].delete_if { |kv| kv["Key"] == k }
  self[:Properties][:Tags].unshift({"Key" => k, "Value" => v}.merge(options))
end