class Chef::Provisioning::AWSDriver::TaggingStrategy::RDS

Attributes

desired_tags[R]
rds_client[R]
rds_object_arn[R]

Public Class Methods

new(rds_client, rds_object_arn, desired_tags) click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb, line 53
def initialize(rds_client, rds_object_arn, desired_tags)
  @rds_client = rds_client
  @rds_object_arn = rds_object_arn
  @desired_tags = desired_tags
end

Public Instance Methods

current_tags() click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb, line 59
def current_tags
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#list_tags_for_resource-instance_method
  resp = rds_client.list_tags_for_resource(
    resource_name: rds_object_arn
  )
  Hash[resp.tag_list.map { |t| [t.key, t.value] }]
end
delete_tags(tag_keys) click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb, line 83
def delete_tags(tag_keys)
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#remove_tags_from_resource-instance_method
  rds_client.remove_tags_from_resource(
    resource_name: rds_object_arn,
    tag_keys: tag_keys
  )
end
set_tags(tags) click to toggle source
# File lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb, line 67
def set_tags(tags)
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#add_tags_to_resource-instance_method
  # Unlike EC2, RDS tags can have a nil value
  tags = tags.map do |k, v|
    if v.nil?
      { key: k }
    else
      { key: k, value: v }
    end
  end
  rds_client.add_tags_to_resource(
    resource_name: rds_object_arn,
    tags: tags
  )
end