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.



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

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.



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

def access_point_name
  @access_point_name
end

#desired_tagsObject (readonly)

Returns the value of attribute desired_tags.



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

def desired_tags
  @desired_tags
end

#elb_clientObject (readonly)

Returns the value of attribute elb_client.



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

def elb_client
  @elb_client
end

Instance Method Details

#current_tagsObject



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

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



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

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



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

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