- Amazon VPC (Virtual Private Cloud) enables you to launch AWS resources into a virtual network that you've defined.
- A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses.
- Instances in either VPC can communicate with each other as if they are within the same network.
- VPC peering can be done between:
- Two VPCs of the same account
- Two VPCs of different accounts
- Two VPCs of different regions (inter-region VPC peering connection)
- Open the Amazon VPC console at https://console.aws.amazon.com/vpc/.
- In the navigation pane, choose Peering Connections, Create Peering Connection.
- Configure the following information, and choose Create Peering Connection when you are done:
- Peering connection name tag = CA-OR (for N. California and Oregon)
- VPC (Requester)* = cmpe281 (N. California)
- Account = My account
- Region = Another Region (Oregon)
- VPC (Accepter): ID of the accepter VPC.
- OK
- In the region selector, select the region of the accepter VPC (Oregon).
- In the navigation pane, choose Peering Connections.
- Select the VPC peering connection that you've created, and choose Actions, Accept Request.
- Accept peering connection request.
- Once your VPC peering connection is active, you must add an entry to your VPC route tables to enable traffic to be directed between the peered VPCs.
- Edit route the route tables by adding the CIDR of the other VPC.
- Since we will be creating the MongoDB cluster between two regions, we will need the MongoDB installed AMI in both the regions. The steps to copy the AMI are given below.
- Open the Amazon EC2 console.
- In the navigation pane, choose AMIs.
- Select the AMI to be copied.
- Select the appropriate destination region (Oregon).
- Copy AMI.