Terraform Hands-on Project: Crafting a Magical AWS Infrastructure! โจโ๏ธDay - 66
๐ Hello, I'm Vishal, an aspiring Information Technology enthusiast currently embarking on a journey towards a Bachelor's degree in Engineering. My passion lies in exploring the dynamic realms of cloud computing and DevOps technologies, where I constantly strive to bridge the gap between innovation and practical implementation.
๐ก As a student of Information Technology, I'm on a mission to absorb knowledge, solve real-world problems, and contribute to the tech community. My academic pursuits fuel my curiosity, and my hands-on experience with cloud and DevOps tools empowers me to navigate the evolving landscape of modern technology.
๐ Join me as I share insights, discoveries, and challenges encountered on this exciting educational and professional adventure. Let's connect, collaborate, and grow together in the ever-expanding world of IT.
๐ Connect with me on social media and let's build a network that fosters learning, sharing, and innovation.
Happy coding! ๐
Hello, fellow cloud architects and Terraform enthusiasts! ๐ Welcome back to our journey in the mystical world of Terraform.
In our previous escapades, we've covered the basics, configured EC2 instances, and now, brace yourselves as we embark on an even grander adventure. Today, our quest involves creating an entire AWS infrastructure using the enchanting powers of Infrastructure as Code (IaC).
Task at Hand: Weaving the Cloud Realms ๐
Step 1: Laying the Foundation - VPC Creation
Our journey begins with the creation of a Virtual Private Cloud (VPC). Picture this as the very fabric of our cloud realm with the illustrious CIDR block 10.0.0.0/16.
resource "aws_vpc" "my_vpc" {
cidr_block = "10.0.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
}

Step 2: Crafting Realms - Subnets Unveiled
Now, let's carve out distinct realms within our VPC - a public subnet (10.0.1.0/24) and a private subnet (10.0.2.0/24).
resource "aws_subnet" "public_subnet" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-east-1a"
}
resource "aws_subnet" "private_subnet" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "10.0.2.0/24"
availability_zone = "us-east-1b"
}

Step 3: Bridging Realms - Internet Gateway and Routes
Connect these realms with an Internet Gateway (IGW) and set up the magical routes.
resource "aws_internet_gateway" "my_igw" {
vpc_id = aws_vpc.my_vpc.id
}
resource "aws_route_table" "public_route_table" {
vpc_id = aws_vpc.my_vpc.id
}
resource "aws_route" "internet_route" {
route_table_id = aws_route_table.public_route_table.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.my_igw.id
}

Step 4: Summoning a Mage - EC2 Instance Unleashed
Let's conjure a virtual mage into our public realm! Equipped with AMI ami-0557a15b87f6559cf, adorned in the armor of a t2.micro, and wielding a security group allowing SSH from anywhere.
resource "aws_instance" "web_server" {
ami = "ami-0557a15b87f6559cf"
instance_type = "t2.micro"
key_name = "my-key-pair"
subnet_id = aws_subnet.public_subnet.id
security_groups = [
aws_security_group.allow_ssh.id,
]
user_data = <<-EOF
#!/bin/bash
sudo apt-get update
sudo apt-get install -y apache2
sudo service apache2 start
EOF
}

Step 5: Enchantment Unleashed - Elastic IP and a Wondrous Website
Bestow our mage with an Elastic IP for permanence and let it enchant the world with a simple website.
resource "aws_eip" "web_server_eip" {
instance = aws_instance.web_server.id
}

Step 6: Grand Finale - Witness the Magic Unfold! ๐
Open your browser and witness the magic as you access the website hosted at the EC2 instance's URL.
There you have it, fellow conjurers of the cloud! A complete AWS infrastructure summoned into existence using Terraform's enchanting IaC techniques. Stay tuned for more magical tasks as we continue our Terraform odyssey. Happy conjuring! ๐๐งโโ๏ธ #TerraformMagic #IaCJourney #AWSInfraCrafting


