Module: AWS::ELB::TaggedItem

Defined in:
lib/aws/elb/tagged_item.rb

Instance Method Summary collapse

Instance Method Details

#add_tag(key, options = {}) ⇒ Object Also known as: tag

Adds a single tag with an optional tag value.

# adds a tag with the key production
resource.tag('production')

# adds a tag with the optional value set to production
resource.tag('role', :value => 'webserver')

Unlike EC2 version, this returns nil

Parameters:

  • key (String)

    The name of the tag to add.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :value (String)

    An optional tag value.



17
18
19
# File 'lib/aws/elb/tagged_item.rb', line 17

def add_tag key, options = {}
  tags[key] = options[:value].to_s
end

#clear_tagsnil

Deletes all tags associated with this EC2 resource.

Returns:

  • (nil)


24
25
26
27
# File 'lib/aws/elb/tagged_item.rb', line 24

def clear_tags
  tags.clear
  nil
end

#tagsResourceTagCollection

Returns a collection that represents only tags belonging to this resource.

Examples:

Manipulating the tags of an EC2 instance

i = ec2.instances["i-123"]
i.tags.to_h                  # => { "foo" => "bar", ... }
i.tags.clear
i.tags.stage = "production"
i.tags.stage                 # => "production"

Returns:

  • (ResourceTagCollection)

    A collection of tags that belong to this resource.



42
43
44
# File 'lib/aws/elb/tagged_item.rb', line 42

def tags
  LoadBalancerTagCollection.new(self, :config => config)
end