Class: Terraframe::AWS::AWSTaggedResource

Inherits:
Resource show all
Defined in:
lib/terraframe/aws/aws_resources.rb

Instance Attribute Summary

Attributes inherited from Resource

#resource_name

Attributes inherited from ScriptItem

#context, #fields, #vars

Instance Method Summary collapse

Methods inherited from Resource

#cleanup_provisioner_type, #connection, #provisioner

Methods inherited from ScriptItem

#id_of, #method_missing, #output_of, #to_json

Constructor Details

#initialize(name, vars, context, &block) ⇒ AWSTaggedResource

Returns a new instance of AWSTaggedResource.



18
19
20
21
22
23
24
25
26
# File 'lib/terraframe/aws/aws_resources.rb', line 18

def initialize(name, vars, context, &block)
  @fields = {}
  @vars = Hashie::Mash.new(vars)

  clear_tags!
  @fields["tags"]["Name"] = name

  instance_eval &block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Terraframe::ScriptItem

Instance Method Details

#clear_tags!Object



33
34
35
# File 'lib/terraframe/aws/aws_resources.rb', line 33

def clear_tags!
  @fields["tags"] = {}
end

#tags(&block) ⇒ Object



28
29
30
31
# File 'lib/terraframe/aws/aws_resources.rb', line 28

def tags(&block)
  tag_set = Terraframe::AWS::AWSTagBlock.new(@vars, @context, &block)
  @fields["tags"].merge!(tag_set.fields)
end