Building a VPC using IaC with Terraform
Journey: 📊 Community Builder 📊
Subject matter: Building on AWS
Task: Build a VPC using IaC via Terraform.
In this article, we build a VPC!
Within this VPC, there are Public and Private subnets, an Internet Gateway, a security group, custom route tables, and a NAT Gateway.
Within the 6 Pillars of the AWS Well-Architected Framework, Operational Excellence will be achieved by using Terraform to deliver an Infrastructure as Code pipeline.
I also plan on doing a similar project using CloudFormation.
The first question is, why?
I have probably completed well over 100 Cloud Quest labs, which has given me a large amount of hands-on experience with many of the products and services AWS offers.
However, one thing that I never had to do was set up the environment from scratch.
With Cloud Quest, the labs are pre-configured and launched as a self-contained environment. Your goal is to use the course material to navigate around the service and then once you have configured the various areas via documented guidance, you have to fix or configure an area to successfully pass the lab quest.
I was very aware that I hadn’t built a VPC.
So I decided to do just that.
Credit: This architecture was created using guidance from Prashant Bhatasana on Medium Here
I also used help from Flavius Dinu Here
What did I use to build this environment?
- Visual Studio Code platform
- Terraform
- AWS CLI
What is built?
- Amazon VPC
- Public and Private subnets
- Security Groups
- Custom Route Tables
- Internet Gateway
- NAT Gateway
As I can build and destroy this environment as I need it to ensure healthy cost optimisation, I plan on using this environment for some other projects as I need to so it effectively becomes a multi-project!
In a production environment, I would also ensure we had resiliency with instances spanning Multiple AZs.
Some of the highlights…
The VPC builds:
AWS Management Console view:
Subnets:
Route Tables:
NAT Gateway:
Internet Gateway:
Elastic IP:
Then… time for IaC destruction!!
My interpretation of the architecture:
[including an EC2 instance serving as a Web Server and a Database instance for illustrative purposes]
Troubleshooting required
I ran into a couple of issues, one of which I documented here: Troubleshooting a Terraform VPC build conflict
I hope you have enjoyed the article, I enjoyed the build!