Module: AWS::EC2::TaggedItem
- Included in:
- Image, Instance, ReservedInstances, ReservedInstancesOffering, ResourceObject, SecurityGroup, Snapshot, Volume
- Defined in:
- lib/aws/ec2/tagged_item.rb
Instance Method Summary collapse
-
#add_tag(key, options = {}) ⇒ Tag
(also: #tag)
Adds a single tag with an optional tag value.
-
#clear_tags ⇒ nil
Deletes all tags associated with this EC2 resource.
-
#tags ⇒ ResourceTagCollection
Returns a collection that represents only tags belonging to this resource.
Instance Method Details
#add_tag(key, options = {}) ⇒ Tag 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')
32 33 34 35 36 37 38 |
# File 'lib/aws/ec2/tagged_item.rb', line 32 def add_tag key, = {} client.({ :resources => [id], :tags => [{ :key => key, :value => [:value].to_s }], }) Tag.new(self, key, .merge(:config => config)) end |
#clear_tags ⇒ nil
Deletes all tags associated with this EC2 resource.
43 44 45 46 |
# File 'lib/aws/ec2/tagged_item.rb', line 43 def client.(:resources => [self.id]) nil end |
#tags ⇒ ResourceTagCollection
Returns a collection that represents only tags belonging to this resource.
61 62 63 |
# File 'lib/aws/ec2/tagged_item.rb', line 61 def ResourceTagCollection.new(self, :config => config) end |