Sha256: aa45480f2b8a3a421cbeaf0ce6d25fad19b144494f12d12f77a5844b031b0932

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

module Awspec::Helper
  module Finder
    module VpcEndpoints
      def find_vpc_endpoint(id)
        res = ec2_client.describe_vpc_endpoints({ vpc_endpoint_ids: [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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awspec-1.31.0 lib/awspec/helper/finder/vpc_endpoints.rb