Class: Chef::Provisioning::AWSDriver::TaggingStrategy::ELB

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elb_client, access_point_name, desired_tags) ⇒ ELB

Returns a new instance of ELB.



8
9
10
11
12
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 8

def initialize(elb_client, access_point_name, desired_tags)
  @elb_client = elb_client
  @access_point_name = access_point_name
  @desired_tags = desired_tags
end

Instance Attribute Details

#access_point_nameObject (readonly)

Returns the value of attribute access_point_name.



6
7
8
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 6

def access_point_name
  @access_point_name
end

#desired_tagsObject (readonly)

Returns the value of attribute desired_tags.



6
7
8
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 6

def desired_tags
  @desired_tags
end

#elb_clientObject (readonly)

Returns the value of attribute elb_client.



6
7
8
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 6

def elb_client
  @elb_client
end

Instance Method Details

#current_tagsObject



14
15
16
17
18
19
20
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 14

def current_tags
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#describe_tags-instance_method
  resp = elb_client.describe_tags({
    load_balancer_names: [access_point_name]
  })
  Hash[resp.tag_descriptions[0].tags.map {|t| [t.key, t.value]}]
end

#delete_tags(tag_keys) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 30

def delete_tags(tag_keys)
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#remove_tags-instance_method
  elb_client.remove_tags({
    load_balancer_names: [access_point_name],
    tags: tag_keys.map {|k| {key: k} }
  })
end

#set_tags(tags) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb', line 22

def set_tags(tags)
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#add_tags-instance_method
  elb_client.add_tags({
    load_balancer_names: [access_point_name],
    tags: tags.map {|k,v| {key: k, value: v} }
  })
end