Skip to content

Commit

Permalink
Fix find vpc_endpoint by Name
Browse files Browse the repository at this point in the history
  • Loading branch information
alpineriveredge committed Jan 27, 2025
1 parent 6493b44 commit 9b96cd8
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/awspec/helper/finder/vpc_endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ module Awspec::Helper
module Finder
module VpcEndpoints
def find_vpc_endpoint(id)
res = ec2_client.describe_vpc_endpoints({ vpc_endpoint_ids: [id] })
begin

Check failure on line 7 in lib/awspec/helper/finder/vpc_endpoints.rb

View workflow job for this annotation

GitHub Actions / Lint

[rubocop] reported by reviewdog 🐶 [Correctable] Style/RedundantBegin: Redundant begin block detected. Raw Output: lib/awspec/helper/finder/vpc_endpoints.rb:7:9: C: [Correctable] Style/RedundantBegin: Redundant begin block detected. begin ^^^^^
res = ec2_client.describe_vpc_endpoints({ vpc_endpoint_ids: [id] })

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

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

Check failure on line 15 in lib/awspec/helper/finder/vpc_endpoints.rb

View workflow job for this annotation

GitHub Actions / Lint

[rubocop] reported by reviewdog 🐶 [Correctable] Style/RedundantReturn: Redundant return detected. Raw Output: lib/awspec/helper/finder/vpc_endpoints.rb:15:11: C: [Correctable] Style/RedundantReturn: Redundant return detected. return resource if resource ^^^^^^

res = ec2_client.describe_vpc_endpoints({
filters: [{ name: 'tag:Name', values: [id] }]
})
rescue Aws::EC2::Errors::InvalidVpcEndpointIdNotFound, Aws::EC2::Errors::InvalidVpcEndpointIdMalformed
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
ret = res.vpc_endpoints.select do |vpce|
vpce.tags.find do |tag|
tag.key == 'Name' && tag.value == id
end
end
end

ret.single_resource(id)
ret.single_resource(id)
end
end
end
end
Expand Down

0 comments on commit 9b96cd8

Please sign in to comment.