Method: Awspec::Helper::Finder::Vpc#select_vpc_peering_connection_by_vpc_id

Defined in:
lib/awspec/helper/finder/vpc.rb

#select_vpc_peering_connection_by_vpc_id(vpc_id, status_code = nil) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/awspec/helper/finder/vpc.rb', line 76

def select_vpc_peering_connection_by_vpc_id(vpc_id, status_code = nil)
  params = {}
  params = { filters: [{ name: 'status-code', values: [status_code] }] } if status_code
  vpc_peering_connections = ec2_client.describe_vpc_peering_connections(params).map do |res|
    res.vpc_peering_connections
  end.flatten
  vpc_peering_connections.select do |conn|
    conn.accepter_vpc_info.vpc_id == vpc_id || conn.requester_vpc_info.vpc_id == vpc_id
  end
end