Module: Awspec::Helper::Finder::VpcEndpoints

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/vpc_endpoints.rb

Instance Method Summary collapse

Instance Method Details

#find_vpc_endpoint(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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