Skip to content

theglad-x/Three-Tier-Architecture-Deployment-on-AWS-with-Terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure and Scalable Three-tier Web Application Deployment on AWS

This project demonstrates how to deploy a three-tier architecture on AWS using Terraform. A three tier architecture consisting of three layers: the web tier, the application tier, and the database tier. Each layer has a specific role and interacts with the other layers to form a scalable and resilient application, with components such as EC2 instances, RDS, Elastic Load Balancer (ELB), VPC, and ASG. This project uses Terraform modules to organize and manage the infrastructure code effectively, making it easily reusable.

  • Web Tier: EC2 instances running in multiple Availability Zones, fronted by an Elastic Load Balancer.
  • Application Tier: EC2 instances for application processing in a private subnets also load-balanced and running in multiple Availability Zones.
  • Database Tier: An Amazon RDS instance running in a private subnets.

Screenshot (342)

Prerequisites

Before you begin, ensure you have:

  • Basic knowledge of Terraform and AWS services such as EC2, ELB, ASG, RDS and VPC
  • Terraform installed on your local machine
  • An AWS account
  • AWS CLI configured with appropriate IAM user credentials (secret access key and access key ID)

Steps

1. Clone the repository

git clone https://github.com/theglad-x/Three-Tier-Architecture-Deployment-on-AWS-with-Terraform.git

2. Change to the project folder

cd Three-Tier-Architecture-Deployment-on-AWS-with-Terraform

3. Create S3 bucket to store the state file

Create S3 bucket for backend to store Terraform state file. The S3 bucket can be created with either

  1. The configuration in ./s3-bucket.tf file
  2. Through the AWS management console

4. Configure email for ASG notification

Open in a text editor main.tf file in the project root directory and configure your email for web tier and app tier ASG notification

5. Configure Terraform Variables

In the project root directory, open terraform.tfvars in a text editor Review and customize the values of the variables according to your reguirement.

  • image_name: Set the value for ami filter
  • my_public_key: Set location of the public key for keypair
  • db_password: Set the database password
  • db_username: Set username for the database
  • ip: Set ip for the host machine

6. Formate configuration files

Run fmt command to fix any syntax error

terraform fmt

7. Initialize Terraform

terraform init

8. Plan the deployment terraform plan

Run the following command to see all resources terraform will create and check if matches your expection

terraform plan

9. Deploy the infrastructure

terraform apply

10. Access the Application

After deployment is complete, the web application can be access via the Elastic Load Balancer's DNS name. Copy the DNS name Terraform will output and paste it into your web browser.

11. Confirm Infrastructure

Login to AWS console to confirm all the resources created

Screenshot (319) Screenshot (320) Screenshot (321) Screenshot (322) Screenshot (323) Screenshot (324) Screenshot (325) Screenshot (326) Screenshot (327) Screenshot (328) Screenshot (329) Screenshot (330) Screenshot (332) Screenshot (333)

Terraform Modules

This project uses Terraform modules to organize and manage the infrastructure code effectively. You can reuse these modules or customize them as needed.

Conclusion

This project demonstrates the power of Terraform in deploying a secure and scalable three-tier web application architecture on AWS. By leveraging Terraform modules and AWS services such as EC2, ELB, RDS, and ASG, this setup ensures high availability, fault tolerance, and ease of management. The modular nature of the code makes it reusable and adaptable to different requirements, allowing for customization and further expansion as needed.

With this setup, you can easily deploy, manage, and scale your infrastructure while maintaining best practices in cloud architecture. Ensure to follow Terraform's best practices for structuring configurations and AWS best practices. Secure sensitive data using Terraform's sensitive attribute and gitignore your .tfvars file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published