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

terraform Article's
30 articles in total
Favicon
Introduction to Terraform: Revolutionizing Infrastructure as Code
Favicon
Serverless NBA Data Lake Application with API Gateway, AWS Lambda, Amazon S3, AWS Glue and Athena Using Terraform
Favicon
Terraform input validation
Favicon
Automating Limit Orders on Polygon with TypeScript, 0x, and Terraform
Favicon
Introducing vulne-soldier: A Modern AWS EC2 Vulnerability Remediation Tool
Favicon
Secrets Management 101: A technical approach with AKS, Terraform, and Vault
Favicon
Semantic Math Editor
Favicon
The Impact of Infrastructure Automation Part 2
Favicon
A Comparative Analysis of Terraform and CloudFormation
Favicon
Deploying Your First Kubernetes Cluster on AWS Using EKS
Favicon
How to Install Terraform on Ubuntu
Favicon
Secrets Management & Security: Hashicorp Vault
Favicon
DIY Project: How To Setup and Host Your Own Free VPN Server on AWS Using Terraform and OpenVPN
Favicon
Terraform: From Beginner to Master with Hands-On Example
Favicon
Lee esto antes de implementar S3 y CloudFront usando Terraform.
Favicon
Lee esto antes de implementar S3 y CloudFront usando Terraform.
Favicon
Navigating AWS EKS with Terraform: Implementing Cluster Auoscaler in your EKS Cluster
Favicon
Master AWS Transit Gateway Management with Terraform: A Step-by-Step Guide
Favicon
Terraform
Favicon
Terraform Session 2: Setup and Build First Project
Favicon
Deploying Your First Server with Terraform: A Beginner's Guide
Favicon
EC2 instances with pre-configured EFS (elastic file system ) using Terraform modules
Favicon
Como um cego total trabalha como devops?
Favicon
Cryptocurrency Notifications System Alert
Favicon
What is Kubernetes Vs Terraform
Favicon
Creating an AWS + NextJS site for the Cloud Resume Challenge
Favicon
Declarative in Terraform: Simple, Until It’s Not! 🚧
Favicon
The Impact of Infrastructure Automation part 1
Favicon
Building an S3 Static Website with CloudFront Using Terraform
Favicon
Code Quality in the Cloud

Featured ones: