Two-Tier AWS Infrastructure with Terraform
terraform fmt -checkOverview
Section titled “Overview”Terraform two-tier AWS infrastructure sample.
What You Will Build
Section titled “What You Will Build”Architecture Diagram
Section titled “Architecture Diagram”Prerequisites
Section titled “Prerequisites”- 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.
Credentials And Cost Warning
Section titled “Credentials And Cost Warning”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.
Step-By-Step Lab
Section titled “Step-By-Step Lab”Use this flow before you run commands:
- Read the cost and credential warning above.
- Review the validation, troubleshooting, cleanup, and portfolio proof sections below.
- Follow the original project guide preserved near the bottom of this page.
- Return to the validation and cleanup checks before you capture portfolio evidence.
Validation Checks
Section titled “Validation Checks”Run the project validation command before and after meaningful changes:
terraform fmt -checkTroubleshooting
Section titled “Troubleshooting”- Run
terraform fmt -checkfirst 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
Section titled “Cleanup”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.
Portfolio Proof
Section titled “Portfolio Proof”- 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
Original Project Guide
Section titled “Original Project Guide”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>
Overview
Section titled “Overview”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.
Features
Section titled “Features”- 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:
- Zero Trust EC2 Ingress: The
web-tier-sgno longer allows open0.0.0.0/0ingress on ports 80/443. The web instances strictly accept traffic downstream from the Application Load Balancer Security Group. - Encrypted RDS at Rest: The
aws-rdsmodule explicitly enforcesstorage_encrypted = trueon the database cluster to comply with modern data residency regulations.
Getting Started
Section titled “Getting Started”Follow these steps to deploy the Two-Tier architecture:
-
Clone the Repository:
Terminal window git clone https://github.com/DevCloudNinjas/DevOps-Projectscd DevOps-Projects/project-11-aws-2tier-terraform/ -
Plan and Apply:
Terminal window terraform initterraform plan -var-file=variables.tfvarsterraform apply -var-file=variables.tfvars --auto-approve -
Cleanup: When done the exploration, run the following to destroy the infrastructure
Terminal window terraform destroy -var-file=variables.tfvars --auto-approve
Project Highlights
Section titled “Project Highlights”-
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.
Detailed Guide
Section titled “Detailed Guide”For an in-depth walkthrough of the project, check out the detailed guide on Hashnode.
Connect with Me
Section titled “Connect with Me”- GitHub: GitHub Profile
- LinkedIn: LinkedIn Profile
Contributions
Section titled “Contributions”Feel free to contribute and adapt this project to suit your needs. We welcome your ideas and improvements.
License
Section titled “License”This project is licensed under the MIT License.
Source Files On GitHub
Section titled “Source Files On GitHub”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.