logo
Published on

VPC Peering

Authors
  • avatar
    Name
    Bowen Y
    Twitter

Configuration

  • Have to add routes to both two subnets' route table.
Route tableDestinationTarget
VPC AVPC A CIDRLocal
VPC B CIDRpcx-11112222
VPC BVPC B CIDRLocal
VPC A CIDRpcx-11112222
  • No unidirection access if only one route is added to one subnet's route table.
Route tableDestinationTarget
VPC AVPC A CIDRLocal
VPC B CIDRpcx-11112222
VPC BVPC B CIDRLocal

OR

Route tableDestinationTarget
VPC AVPC A CIDRLocal
VPC BVPC B CIDRLocal
VPC A CIDRpcx-11112222

No traffic allowed from A -> B and B -> A.

Steps to create VPC peering

  1. Create VPC peering requests(in account A)
  2. Accept VPC peering requests(in account B)
  3. Update/Create route tables to transmit all requests to the peered CIDR to peered VPC(in account A)
  4. Update/Create route tables to transmit all requests to the peered CIDR to peered VPC(in account B)
  5. (Optional) Allow DNS resolving(in account A and B)
  6. (Optional) Associate Private Hosted Zone following the steps below(in account A and B)
  7. Update security groups (Can use OTHER_AWS_ACCOUNT/SG_ID in the inbound/outbound rule to allow traffic from security group in other aws accounts)

VPC Peering with Private Hosted Zone

This process has to be done using command line.

# The AWS account that created the private hosted zone must first submit a CreateVPCAssociationAuthorization request

aws route53 create-vpc-association-authorization --hosted-zone-id HOSTED_ZONE_ID --vpc VPCRegion=us-west-2,VPCId=VPC_ID_IN_OTHER_ACCOUNT

# Then the account that created the VPC must submit an AssociateVPCWithHostedZone request.
aws route53 associate-vpc-with-hosted-zone --hosted-zone-id SAME_HOSTED_ZONE_ID --vpc VPCRegion=us-west-2,VPCId=SAME_VPC_ID