Method: Fog::Compute::AWS::Real#create_tags

Defined in:
lib/fog/compute/requests/aws/create_tags.rb

#create_tags(resources, tags) ⇒ Object

Adds tags to resources

Parameters

  • resources<~String> - One or more resources to tag

  • tags<~String> - hash of key value tag pairs to assign

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘return’<~Boolean> - success?

Amazon API Reference



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/requests/aws/create_tags.rb', line 21

def create_tags(resources, tags)
  resources = [*resources]
  for key, value in tags
    if value.nil?
      tags[key] = ''
    end
  end
  params = {}
  params.merge!(Fog::AWS.indexed_param('ResourceId', resources))
  params.merge!(Fog::AWS.indexed_param('Tag.%d.Key', tags.keys))
  params.merge!(Fog::AWS.indexed_param('Tag.%d.Value', tags.values))
  request({
    'Action'            => 'CreateTags',
    :parser             => Fog::Parsers::Compute::AWS::Basic.new
  }.merge!(params))
end