EC2 - Cross region VPC peering bug (#4764)
This commit is contained in:
parent
f45da41b33
commit
8f63ce073e
@ -3919,13 +3919,6 @@ class VPCBackend(object):
|
|||||||
self.vpc_refs[self.__class__].add(weakref.ref(self))
|
self.vpc_refs[self.__class__].add(weakref.ref(self))
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_vpc_refs(cls):
|
|
||||||
for inst_ref in cls.vpc_refs[cls]:
|
|
||||||
inst = inst_ref()
|
|
||||||
if inst is not None:
|
|
||||||
yield inst
|
|
||||||
|
|
||||||
def create_vpc(
|
def create_vpc(
|
||||||
self,
|
self,
|
||||||
cidr_block,
|
cidr_block,
|
||||||
@ -3975,13 +3968,6 @@ class VPCBackend(object):
|
|||||||
raise InvalidVPCIdError(vpc_id)
|
raise InvalidVPCIdError(vpc_id)
|
||||||
return self.vpcs.get(vpc_id)
|
return self.vpcs.get(vpc_id)
|
||||||
|
|
||||||
# get vpc by vpc id and aws region
|
|
||||||
def get_cross_vpc(self, vpc_id, peer_region):
|
|
||||||
for vpcs in self.get_vpc_refs():
|
|
||||||
if vpcs.region_name == peer_region:
|
|
||||||
match_vpc = vpcs.get_vpc(vpc_id)
|
|
||||||
return match_vpc
|
|
||||||
|
|
||||||
def describe_vpcs(self, vpc_ids=None, filters=None):
|
def describe_vpcs(self, vpc_ids=None, filters=None):
|
||||||
matches = self.vpcs.copy().values()
|
matches = self.vpcs.copy().values()
|
||||||
if vpc_ids:
|
if vpc_ids:
|
||||||
|
@ -13,9 +13,9 @@ class VPCPeeringConnections(BaseResponse):
|
|||||||
if peer_region == self.region or peer_region is None:
|
if peer_region == self.region or peer_region is None:
|
||||||
peer_vpc = self.ec2_backend.get_vpc(self._get_param("PeerVpcId"))
|
peer_vpc = self.ec2_backend.get_vpc(self._get_param("PeerVpcId"))
|
||||||
else:
|
else:
|
||||||
peer_vpc = self.ec2_backend.get_cross_vpc(
|
from moto.ec2.models import ec2_backends
|
||||||
self._get_param("PeerVpcId"), peer_region
|
|
||||||
)
|
peer_vpc = ec2_backends[peer_region].get_vpc(self._get_param("PeerVpcId"))
|
||||||
vpc = self.ec2_backend.get_vpc(self._get_param("VpcId"))
|
vpc = self.ec2_backend.get_vpc(self._get_param("VpcId"))
|
||||||
vpc_pcx = self.ec2_backend.create_vpc_peering_connection(vpc, peer_vpc, tags)
|
vpc_pcx = self.ec2_backend.create_vpc_peering_connection(vpc, peer_vpc, tags)
|
||||||
template = self.response_template(CREATE_VPC_PEERING_CONNECTION_RESPONSE)
|
template = self.response_template(CREATE_VPC_PEERING_CONNECTION_RESPONSE)
|
||||||
|
Loading…
Reference in New Issue
Block a user