๐ Overview:
This repository showcases a Terraform-based deployment of a scalable and secure AWS infrastructure, designed as a practical test for DevOps skills in Infrastructure as Code (IaC) and AWS Cloud services.
๐ก Objective:
The aim is to automate the deployment of a multi-server environment on AWS using Terraform, focusing on cost-efficiency by leveraging AWS's free tier resources. This project tests the candidate's ability to create a functional and secure cloud infrastructure within specified constraints.
๐ ๏ธ Technology Stack:
- Terraform: ๐ For provisioning and managing AWS resources as code.
- AWS EC2: ๐ป Two instances, one with Nginx and another with Apache, to demonstrate a multi-server setup.
- AWS Application Load Balancer (ALB): ๐ To distribute incoming traffic between the two EC2 instances.
- AWS Security Groups: ๐ To define traffic rules for the EC2 instances and the ALB, ensuring security best practices.
This README offers a step-by-step guide on deploying the infrastructure, with detailed explanations of the Terraform configurations used.
- ๐๏ธ Solution Architecture
- โ๏ธ Terraform Configuration
- ๐ Provisioning and Deployment
- ๐งช Testing the Infrastructure
The designed infrastructure aims to provide a basic, scalable, and secure web application environment on AWS.
- Application Load Balancer (ALB): ๐ Directs traffic to EC2 instances based on rules.
- EC2 Instances:
- Server 01: ๐ข Runs Nginx.
- Server 02: ๐ต Runs Apache.
- Security Groups: ๐ Separate groups for ALB and EC2 instances to adhere to the principle of least privilege.
The Terraform setup is organized into multiple files for better manageability:
ALB-application.tf
: Configures the ALB.ec2instance-apache.tf
&ec2instance-nginx.tf
: Provisions the EC2 instances.security-group-*.tf
: Defines the security groups and their rules.
- AWS Account ๐
- Terraform installed ๐ ๏ธ
- AWS CLI configured ๐ง
- Initialize Terraform: ๐ฑ
terraform init
- Plan the Deployment: ๐:
terraform plan
- Apply the Configuration: โ
terraform apply
After deployment, the ALB's DNS name, provided as a Terraform output, serves as the entry point for testing.
The ALB URL is output by Terraform upon successful deployment. Look for an output variable named something like alb_dns_name
.
Use a browser or a tool like curl
to make requests to the ALB URL. You should see responses alternately from the Nginx and Apache servers, indicating successful load balancing.
curl -X GET <alb_dns_name>