module Awspec::Helper::Finder::VpcEndpoints

Public Instance Methods

find_vpc_endpoint(id) click to toggle source
# File lib/awspec/helper/finder/vpc_endpoints.rb, line 6
def find_vpc_endpoint(id)
  res = ec2_client.describe_vpc_endpoints({
                                            filters: [{ name: 'vpc-endpoint-id', values: [id] }]
                                          })

  ret = res.vpc_endpoints.select do |vpce|
    vpce.vpc_endpoint_id == id
  end

  resource = ret.single_resource(id)
  return resource if resource

  res = ec2_client.describe_vpc_endpoints({
                                            filters: [{ name: 'tag:Name', values: [id] }]
                                          })

  ret = res.vpc_endpoints.select do |vpce|
    vpce.tags.find do |tag|
      tag.key == 'Name' && tag.value == id
    end
  end

  ret.single_resource(id)
end