module Outliers::Filters::Aws::Ec2::Tags

Public Instance Methods

filter_tag(value) click to toggle source
# File lib/outliers/filters/aws/ec2/tags.rb, line 7
def filter_tag(value)
  tag_name  = value.split(':').first
  tag_value = value.split(':').last
  logger.info "Loading filter by tag '#{tag_name}' equals '#{tag_value}'."
  list.select do |r|
    if r.tags.has_key? tag_name
      value = r.tags[tag_name]
      result = value == tag_value
      logger.debug "'#{r.id}' has tag '#{tag_name}' with value '#{value}'. #{result ? 'Matches' : 'Does not match'} filter."
      result
    else
      logger.debug "'#{r.id}' does not have tag '#{tag_name}'"
      false
    end
  end
end