Logo

dev-resources.site

for different kinds of informations.

Master AWS Transit Gateway Management with Terraform: A Step-by-Step Guide

Published at
1/12/2025
Categories
aws
cloud
terraform
networking
Author
damdev95
Categories
4 categories in total
aws
open
cloud
open
terraform
open
networking
open
Author
8 person written this
damdev95
open
Master AWS Transit Gateway Management with Terraform: A Step-by-Step Guide

The Solace Fashion App is ready to redefine how customers shop and engage with style. And at the heart of this exciting journey lies a critical mission: designing and deploying a robust Virtual Private Cloud (VPC) architecture to power it all.

As the cloud network engineer, you are entrusted with the responsibility of turning this vision into a seamless, scalable, and secure reality. From planning subnets and routing tables to implementing security policies that safeguard sensitive user data, your role is to lay the foundation that ensures the app operates flawlessly under any circumstance. This is more than just building infrastructure; itโ€™s about delivering the reliability, performance, and agility needed to match the bold ambitions of the Solace Fashion App.

Letโ€™s dive into how weโ€™ll bring this cloud architecture to life and ensure saclability.
The architecture consists of the following virtual private clouds (VPCs):

  1. Frontend App VPC: 10.10.100.0/16
  2. Backend VPC: 172.30.100.0/16
  3. Database VPC: 192.168.100.0/16

The objectives of the architecture are as follows:

  • Restrict Communication: Only allow the App VPC (10.10.100.0/24) to connect to the Backend VPC (172.30.100.0/24).
  • Controlled Access: Permit the Backend VPC (172.30.100.0/24) to communicate with the Database VPC (192.168.100.0/24).
  • Enforce Isolation: Ensure that direct communication between the App VPC and the Database VPC is strictly prohibited.

We are utilizing Terraform to efficiently manage the development and deployment of the architecture.

  • Develop Terraform code in a modular structure to enhance maintainability and efficiency by isolating components like VPCs, subnets, and transit gateway into reusable modules.

folder

  • Using a transit gateway to efficiently manage and centralize the connections between VPCs, ensuring scalability, simplified routing, and streamlined network management.

architecture

  • Using the following commands to install terraform
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install terraform
Enter fullscreen mode Exit fullscreen mode

terrform version

  • Applying aws credentials on the terminal, either using aws configure or environment variables on your working terminal

  • The Transit Gateway comprises three key components:

    1. Attachment: Connects VPCs, on-premises networks, or other resources to the Transit Gateway.
    2. Route: Defines the traffic flow between attachments through routing tables.
    3. Propagation: Automatically shares routes from attached resources to the Transit Gateway routing tables, enabling dynamic updates.
  • Creating each vpc using terraform

each vpc

  • Creating the transit gateway and each vpc attachment and route-table

tgw

module tgw

for testing purpose, I will be using the public subnet only

  • Creating EC2 instances for reachability tests to verify network connectivity between VPCs.

ec2-instance

  • Initializing the terraform code using terrfarom init

tf init

  • Formatting the terraform code using terraform fmt

tf fmt

  • Planning the terraform code using terraform plan

tf plan

  • Applying the terraform code after the plan was successful using terraform apply --auto-approve

tf apply

tf success

  • Testing connectivity from Frontend VPC

PING TO BACKEND VPC REACHABLE

ping 1

PING TO DATABASE VPC NOT REACHABLE

ping 2

  • Testing connectivity from Database VPC

PING TO BACKEND VPC REACHABLE

ping 3

PING TO FRONTEND APP VPC NOT REACHABLE

Image description

Whaooooo!!!
Been a long ride, I hope you follow through and practice at your pace
Check the Project_CodeBase

networking Article's
30 articles in total
Favicon
Comparing VPN Performance: State-of-the-Art Solutions in Stable vs. Unreliable Networks
Favicon
VPN Peering "Region to Region "
Favicon
Introduction To Networking
Favicon
Demistfying AWS VPC Lattice
Favicon
Integrating OpenShift CoreDNS with Active Directory DNS
Favicon
The Speakeasy Door to Your Network - Port Knocking (2)
Favicon
The Speakeasy Door to Your Network - Port Knocking (1)
Favicon
6 Popular Types of Hyperconverged Infrastructure
Favicon
Learn a little about the patriarchal protocol of the internet, the father of tcp/ip!!
Favicon
OpenShift - Networking
Favicon
Master Virtual Networking as a Freelancer
Favicon
Guide to TCP/IP Ports and UDP Ports
Favicon
Important Port Numbers in Networking and Open-Source Projects
Favicon
10/10. Would Route Again!
Favicon
Optimize Your IT Infrastructure with Expert IT Consultation Services
Favicon
How Data Travels Through the Internet: Networking | OSI model
Favicon
Half-Duplex vs Full-Duplex: What are the Differences?
Favicon
About IRC - Internet Relay Chat
Favicon
Importance of Cisco in IT Networking in 2025
Favicon
Fixing OpenVPN Connection Issues in Ubuntu 24.04
Favicon
Master AWS Transit Gateway Management with Terraform: A Step-by-Step Guide
Favicon
IP Whitelisting, the silent killer
Favicon
5 Strategies for Successful Business Development
Favicon
Implementasi Infrastruktur Jaringan Virtual dengan Protokol OSPF
Favicon
How to setup an Azure Machine Learning Workspace securely๐Ÿ›ก๏ธ๐Ÿ”’๐Ÿ”‘
Favicon
5 Study Tips to Pass the CCNA Certification Exam
Favicon
GossipSampling - A Stand Alone Peer Sampling Service
Favicon
Deploying an Application Using CloudFormation with CDN Integration
Favicon
Difference between AWS Security Groups and NACL
Favicon
5G and Wi-Fi 6: The Future of Wireless Networking

Featured ones: