class Awful::Vpce

Constants

COLORS

Public Instance Methods

color(string) click to toggle source
# File lib/awful/vpce.rb, line 17
def color(string)
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
end
dump(*ids) click to toggle source
# File lib/awful/vpce.rb, line 48
def dump(*ids)
  ec2.describe_vpc_endpoints(
    filters: [{name: 'vpc-endpoint-id', values: ids}]
  ).vpc_endpoints.output do |endpoints|
    puts YAML.dump(endpoints.map{ |e| stringify_keys(e.to_hash) })
  end
end
ls(*ids) click to toggle source
# File lib/awful/vpce.rb, line 27
def ls(*ids)
  filters = [
    { name: 'vpc-endpoint-id',    values: ids },
    { name: 'vpc-id',             values: Array(options[:vpc]) },
    { name: 'service-name',       values: Array(options[:service]).map { |s| "com.amazonaws.#{ENV['AWS_REGION']}.#{s.downcase}" } },
    { name: 'vpc-endpoint-state', values: Array(options[:state]) },
  ].reject { |f| f[:values].empty? }
  filters = nil if filters.empty?

  ec2.describe_vpc_endpoints(filters: filters).vpc_endpoints.output do |endpoints|
    if options[:long]
      print_table endpoints.map { |e|
        [e.vpc_endpoint_id, e.vpc_id, e.service_name, color(e.state), e.creation_timestamp]
      }
    else
      puts endpoints.map(&:vpc_endpoint_id)
    end
  end
end