Skip to content

Two-Tier AWS Infrastructure with Terraform

Level:Intermediate
Time:2-3 hours
Cost:medium
Works locally:No
Cloud creds:Yes
Cleanup:Yes
Reviewed:2026-05-30
Validation:terraform fmt -check

Terraform two-tier AWS infrastructure sample.

Outcome Plan/apply evidence plus destroy proof
Tools used Terraform, EC2, VPC, AWS
Best fit Intermediate - 2-3 hours
Student workstation Repository files IaC plan AWS account Validation proof
  • Install or review: Terraform, EC2, VPC, AWS.
  • Use your own cloud account credentials and keep them out of commits.
  • This project expects cloud resources, so verify budget alerts and cleanup first.
  • Open the safety guide before running commands that create infrastructure.
Cost and credential stance

Cost risk is medium. Cloud target: AWS. Cloud credentials needed: Yes. Always use your own account, never commit secrets, and confirm cleanup before creating paid infrastructure.

Use this flow before you run commands:

  1. Read the cost and credential warning above.
  2. Review the validation, troubleshooting, cleanup, and portfolio proof sections below.
  3. Follow the original project guide preserved near the bottom of this page.
  4. Return to the validation and cleanup checks before you capture portfolio evidence.

Run the project validation command before and after meaningful changes:

Terminal window
terraform fmt -check
  • Run terraform fmt -check first so local tooling issues are visible early.
  • If a command fails, check tool versions, working directory, and required environment variables.
  • For cloud failures, confirm account identity, region, quotas, and least-privilege IAM.

Cleanup is available or expected for this lab. Use the cleanup or destroy steps in the guide below, then confirm that local clusters, containers, cloud resources, buckets, state files, and CI secrets are no longer active.

  • Validation command output: terraform fmt -check
  • Screenshot or terminal proof: Plan/apply evidence plus destroy proof
  • Notes explaining what changed, what failed, and how you fixed it
  • Cleanup evidence, especially for cloud or Kubernetes resources

The original README content is preserved here for lab-specific commands and context. Headings are intentionally demoted so the page outline stays focused on the standard lab flow.

<div class="external-image-reference"> <strong>External image reference</strong> <a href="https://img.shields.io/badge/Connect%20with%20me%20on-LinkedIn-blue.svg" target="_blank" rel="noopener noreferrer">LinkedIn</a> </div> <div class="external-image-reference"> <strong>External image reference</strong> <a href="https://img.shields.io/github/stars/DevCloudNinjas.svg?style=social" target="_blank" rel="noopener noreferrer">GitHub</a> </div> <div class="external-image-reference"> <strong>External image reference</strong> <a href="https://img.shields.io/badge/AWS-%F0%9F%9B%A1-orange" target="_blank" rel="noopener noreferrer">AWS</a> </div> <div class="external-image-reference"> <strong>External image reference</strong> <a href="https://img.shields.io/badge/Terraform-%E2%9C%A8-lightgrey" target="_blank" rel="noopener noreferrer">Terraform</a> </div>
External image reference two-tier

Welcome to the Terraform project for deploying a Two-Tier architecture on AWS! This project adopts a modular and security-enhanced approach to create a scalable and maintainable infrastructure.

  • Modular Structure: The project is organized into dedicated modules for each AWS service, promoting reusability and maintainability.
  • Security Focus: Utilize IAM roles and policies to ensure a secure infrastructure.
  • Infrastructure as Code (IaC): Deploy and manage your infrastructure using Terraform, enabling version control and reproducibility.
  • Service-Specific Modules: Each module corresponds to a specific AWS service, allowing for targeted management.
🛡️ 2026 DevSecOps Enhancements (What You Will Learn)
Section titled “🛡️ 2026 DevSecOps Enhancements (What You Will Learn)”

This repository’s Terraform modules have been hardened to comply with 2026 AWS Security architectural standards. Note the following improvements:

  1. Zero Trust EC2 Ingress: The web-tier-sg no longer allows open 0.0.0.0/0 ingress on ports 80/443. The web instances strictly accept traffic downstream from the Application Load Balancer Security Group.
  2. Encrypted RDS at Rest: The aws-rds module explicitly enforces storage_encrypted = true on the database cluster to comply with modern data residency regulations.

Follow these steps to deploy the Two-Tier architecture:

  1. Clone the Repository:

    Terminal window
    git clone https://github.com/DevCloudNinjas/DevOps-Projects
    cd DevOps-Projects/project-11-aws-2tier-terraform/
  2. Plan and Apply:

    Terminal window
    terraform init
    terraform plan -var-file=variables.tfvars
    terraform apply -var-file=variables.tfvars --auto-approve
  3. Cleanup: When done the exploration, run the following to destroy the infrastructure

    Terminal window
    terraform destroy -var-file=variables.tfvars --auto-approve
  • VPC: The Foundation: Create a robust Virtual Private Cloud (VPC) to establish a secure and isolated environment for your application.

  • Load Balancing Magic: Harness the power of the Application Load Balancer (ALB) to intelligently distribute incoming traffic across multiple EC2 instances, ensuring optimal performance and high availability.

  • Auto Scaling Wonders: Leverage the Auto Scaling Group to dynamically adjust the number of EC2 instances based on demand. This ensures your application scales seamlessly, providing resilience and cost efficiency.

  • Database Sorcery: Dive into the world of managed databases with Amazon RDS. Easily deploy, scale, and manage relational databases without the operational overhead.

  • DNS Mastery: Achieve domain registration and DNS management excellence with Amazon Route 53. Seamlessly connect your applications to the internet while ensuring high availability and low-latency responses.

  • Web Application Firewall (WAF) Protection: Safeguard your applications from web exploits and ensure a secure user experience with AWS WAF, a web application firewall that helps protect your web applications from common web exploits.

  • Content Delivery Network (CDN) Acceleration: Boost the delivery of your content globally with a Content Delivery Network. Accelerate load times, enhance user experience, and reduce latency using Amazon CloudFront.

  • SSL Certificate Management with ACM: Ensure secure communication between your users and the application with Amazon Certificate Manager (ACM). Easily provision, manage, and deploy SSL/TLS certificates.

  • IAM for Robust Security: Implement robust security measures with Identity and Access Management (IAM). Define granular permissions and access controls to secure your AWS resources.

  • Infrastructure as Code (IaC) Excellence: Embrace Infrastructure as Code (IaC) with Terraform, facilitating the provisioning and management of AWS resources in a declarative and scalable manner.

These project highlights showcase the comprehensive AWS services integrated into the Two-Tier architecture, providing a solid foundation for your applications with security, scalability, and performance at the forefront.

For an in-depth walkthrough of the project, check out the detailed guide on Hashnode.

Feel free to contribute and adapt this project to suit your needs. We welcome your ideas and improvements.

This project is licensed under the MIT License.

External image reference Source image
Use the guide first.

The full learning flow stays on this page. Open GitHub only when a step asks you to inspect code, fork the lab, or download source assets.