class Chef::Provisioning::AWSDriver::TaggingStrategy::AutoScaling

Attributes

auto_scaling_client[R]
desired_tags[R]
group_name[R]

Public Class Methods

new(auto_scaling_client, group_name, desired_tags) click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb, line 26
def initialize(auto_scaling_client, group_name, desired_tags)
  @auto_scaling_client = auto_scaling_client
  @group_name = group_name
  @desired_tags = desired_tags
end

Public Instance Methods

current_tags() click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb, line 32
def current_tags
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_tags-instance_method
  resp = auto_scaling_client.describe_tags(
    filters: [
      {
        name: "auto-scaling-group",
        values: [group_name]
      }
    ]
  )
  Hash[resp.tags.map { |t| [t.key, t.value] }]
end
delete_tags(tag_keys) click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb, line 60
def delete_tags(tag_keys)
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#delete_tags-instance_method
  auto_scaling_client.delete_tags(
    tags: tag_keys.map do |k|
      {
        resource_id: group_name,
        key: k,
        value: nil,
        resource_type: "auto-scaling-group",
        propagate_at_launch: false
      }
    end
  )
end
set_tags(tags) click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb, line 45
def set_tags(tags)
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#create_or_update_tags-instance_method
  auto_scaling_client.create_or_update_tags(
    tags: tags.map do |k, v|
      {
        resource_id: group_name,
        key: k,
        value: v,
        resource_type: "auto-scaling-group",
        propagate_at_launch: false
      }
    end
  )
end