Terraform40Days

40-Day Hands-On Learning Schedule

Day 1: Terraform Installation & Basic Commands - Create a Local File


Day 2: AWS Provider - Configure Your Region


Day 3: AWS S3 Bucket - Create, Upload, Enable Versioning


Day 4: Variables - Parameterize Your S3 Bucket Name


Day 5: Output Values & Data Source - Fetch S3 Bucket ARN

Day 6: Terraform State - Inspect and Understand Local State


Day 7: Basic VPC Setup - Create VPC and Subnet


Day 8: Security Group - Allow SSH and HTTP Traffic


Day 9: EC2 Instance - Launch in Your VPC


Day 10: IAM Role - Grant S3 Read-Only Access to EC2

Day 11: Elastic Load Balancer (ELB) - Create and Target EC2


Day 12: Local Module - Create Reusable S3 Bucket Module


Day 13: Public Module - Explore and Use a VPC Module from the Registry


Day 14: Remote State - Configure S3 Backend for State Storage


Day 15: State Locking - Set Up DynamoDB for Concurrency Control


Day 16: Provisioner (remote-exec) - Install a Basic Web Server on EC2


Day 17: Data Source (aws_ami) - Dynamically Lookup the Latest Amazon Linux AMI


Day 18: Terraform Cloud - Sign Up and Connect Your Repository


Day 19: Terraform Workspaces - Manage Dev and Prod S3 Buckets


Day 20: Terraform Format and Style - Use terraform fmt and Understand Style Conventions

Week 5: Real-World Projects - Build and Deploy (Days 21–25)


Days 21–25: Project 1 - Basic Web Application Infrastructure

🎯 Goal:

Provision a basic infrastructure for a web application, including a VPC with public and private subnets, an EC2 instance in the private subnet, and a NAT Gateway in the public subnet.


🧠 Concepts Covered:


πŸ›  Hands-On Tasks:

  1. Create VPC and Subnets
    • Define a custom VPC.
    • Create a public and a private subnet in different availability zones.
  2. Internet Gateway & Route Table (Public)
    • Create and attach an Internet Gateway to your VPC.
    • Define a public route table and associate it with the public subnet.
  3. NAT Gateway & Route Table (Private)
    • Allocate an Elastic IP.
    • Create a NAT Gateway in the public subnet.
    • Create a private route table that routes internet traffic via the NAT Gateway and associate it with the private subnet.
  4. EC2 Instance in Private Subnet
    • Launch an EC2 instance in the private subnet.
    • Use a security group allowing SSH and HTTP from your IP (via NAT).
  5. Test Connectivity
    • Use a bastion (jump) host or Session Manager to verify access to the instance.
    • Install a basic web server (e.g., nginx) using remote-exec.

βœ… Validation:


πŸ“¦ Suggested File Structure:

Project 1: Basic Web Application Infrastructure

Folder Structure:

Week 5: Real-World Projects - Build and Deploy (Days 26–30)


Days 26–30: Project 2 - Scalable Web Application with Load Balancer and Auto Scaling

🎯 Goal:

Enhance the infrastructure from Project 1 by adding an Application Load Balancer (ALB) and an Auto Scaling Group (ASG) to ensure the web application can scale automatically based on traffic.


🧠 Concepts Covered:


πŸ›  Hands-On Tasks:

  1. Provision ALB
    • Define an Application Load Balancer in your VPC.
    • Configure listeners for HTTP/HTTPS (optional).
    • Set up target groups to register EC2 instances.
  2. Security Group for ALB
    • Create a new security group for the ALB allowing inbound HTTP/HTTPS (ports 80/443).
  3. Configure EC2 Auto Scaling Group
    • Define an Auto Scaling Group for EC2 instances.
    • Use an EC2 Launch Template to define instance settings (AMI, instance type, security group).
    • Attach the EC2 instances to the target group of the ALB.
  4. Configure Health Checks
    • Set up health checks to monitor the health of instances in the target group.
    • Ensure traffic is only routed to healthy instances.
  5. Test Scalability
    • Monitor the auto scaling behavior by adjusting the desired capacity or triggering traffic.
    • Verify that new instances are spun up and removed based on traffic load.

βœ… Validation:


πŸ“¦ Suggested File Structure:

Project 2: Scalable Web Application with Load Balancer and Auto Scaling

Folder Structure:


Project 1: Basic Web Application Infrastructure

Folder Structure:

Week 6: Real-World Projects - Build and Deploy (Days 31–35)


Days 31–35: Project 3 - Deploying a Static Website with S3 and CloudFront

🎯 Goal:

Provision a static website using an S3 bucket for hosting, and configure CloudFront to distribute the website globally.


🧠 Concepts Covered:


πŸ›  Hands-On Tasks:

  1. Create an S3 Bucket for Static Website Hosting
    • Provision an S3 bucket configured for static website hosting.
    • Configure index.html and error.html as the entry points.
  2. Upload Website Files to S3
    • Use Terraform to upload HTML, CSS, and JS files into the S3 bucket.
  3. Configure Bucket Policy for Public Access
    • Define a bucket policy to allow public access to the static website files.
  4. Provision a CloudFront Distribution
    • Set up a CloudFront distribution to serve content from the S3 bucket.
    • Configure the S3 bucket URL as the origin of the distribution.
    • Optionally, configure SSL/TLS for secure access.
  5. DNS Configuration with Route 53 (Optional)
    • If using Route 53, create a DNS record to map your custom domain to the CloudFront distribution.

βœ… Validation:


πŸ“¦ Suggested File Structure:

Project 3: Deploying a Static Website with S3 and CloudFront

Folder Structure:

Week 7: Real-World Projects - Build and Deploy (Days 36–40)


Days 36–40: Project 4 - Building a Simple Database Infrastructure (RDS)

🎯 Goal:

Provision an Amazon RDS instance (e.g., PostgreSQL or MySQL) and configure necessary security group access for the database.


🧠 Concepts Covered:


πŸ›  Hands-On Tasks:

  1. Provision an RDS Instance
    • Create an RDS instance using Terraform.
    • Choose a suitable database engine (PostgreSQL or MySQL).
    • Specify key configurations such as instance type, storage type, username, password, and database name.
  2. Configure Security Groups for Database Access
    • Define a security group that allows inbound connections on the appropriate port (e.g., 5432 for PostgreSQL, 3306 for MySQL).
    • Attach the security group to your RDS instance.
  3. Backup and Snapshot Configuration (Optional)
    • Configure automatic backups for the RDS instance.
    • Optionally, create a manual snapshot of the database after provisioning.
  4. Parameter Group Configuration (Optional)
    • Create a custom parameter group for your RDS instance to adjust default database settings (e.g., max connections, query cache).
  5. IAM Role (Optional)
    • If necessary, create an IAM role and assign it to your RDS instance for additional features like S3 integration or IAM database authentication.

βœ… Validation:


πŸ“¦ Suggested File Structure:

Project 4: Building a Simple Database Infrastructure (RDS)

Folder Structure: