0
0
AWScloud~30 mins

VPC peering concept in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
VPC Peering Concept
📖 Scenario: You are working as a cloud engineer for a company that has two separate Virtual Private Clouds (VPCs) in AWS. These VPCs need to communicate securely with each other without using the internet. To achieve this, you will set up a VPC peering connection between them.
🎯 Goal: Build a simple AWS VPC peering connection configuration using Terraform. You will create two VPCs, then configure a peering connection between them so they can communicate privately.
📋 What You'll Learn
Create two AWS VPCs with specific CIDR blocks
Create a VPC peering connection between the two VPCs
Add route table entries to allow traffic between the VPCs
Use Terraform syntax and best practices
💡 Why This Matters
🌍 Real World
Companies often have multiple VPCs for different teams or applications. VPC peering allows these VPCs to communicate securely without using the internet.
💼 Career
Cloud engineers and architects frequently set up VPC peering to enable private network communication between AWS environments.
Progress0 / 4 steps
1
Create two AWS VPCs
Create two AWS VPCs using Terraform. Name the first VPC vpc_a with CIDR block 10.0.0.0/16. Name the second VPC vpc_b with CIDR block 10.1.0.0/16. Use the resource type aws_vpc for both.
AWS
Need a hint?

Use resource "aws_vpc" "vpc_a" and resource "aws_vpc" "vpc_b" blocks with cidr_block and tags.

2
Create a VPC peering connection
Create a VPC peering connection resource called vpc_peering between vpc_a and vpc_b. Use the resource type aws_vpc_peering_connection. Set vpc_id to aws_vpc.vpc_a.id and peer_vpc_id to aws_vpc.vpc_b.id. Add a tag with Name = "vpc_peering_connection".
AWS
Need a hint?

Use resource "aws_vpc_peering_connection" "vpc_peering" with vpc_id and peer_vpc_id referencing the VPCs.

3
Add route tables for VPC A
Create a route table resource called rtb_a for vpc_a using aws_route_table. Add a route to rtb_a with destination CIDR block 10.1.0.0/16 that uses the VPC peering connection aws_vpc_peering_connection.vpc_peering.id. Use the resource aws_route named route_a_to_b.
AWS
Need a hint?

Create aws_route_table for vpc_a and add a aws_route with the peering connection ID.

4
Add route tables for VPC B
Create a route table resource called rtb_b for vpc_b using aws_route_table. Add a route to rtb_b with destination CIDR block 10.0.0.0/16 that uses the VPC peering connection aws_vpc_peering_connection.vpc_peering.id. Use the resource aws_route named route_b_to_a.
AWS
Need a hint?

Create aws_route_table for vpc_b and add a aws_route with the peering connection ID.