What is 3-Tier Architecture?
Three-tier architecture is a software architecture pattern that divides an application into three interconnected layers: presentation, logic, and data. This design helps improve scalability, maintainability, and separation of concerns in software development.
Resources needed to be created are:-
Resources we need to install in our Web-Servers and DB-Server are:-
Install httpd in both the Web-Server:-
sudo yum install httpd -y
sudo systemctl start httpd -y
systemctl status httpd
Install mysql in DB-Server:-
sudo yum install mysql -y
How to execute our Terraform scripts:-
terraform init
terraform validate
terraform plan
terraform apply
terraform destroy - After your project is finished execute this command
After terraform apply then switch to our both Web-Server & DB-Server created by using Terraform:- ssh -i <keypair.pem> ec2-user@publicip_of_server-1 and Start our httpd service. Do the same with Server 2.
Then go to DB-Server:- ssh -i <keypair.pem> DB-Server_Private-IP and install mysql.
Final-Output:-
Finally, our complete 3-Tier Application is up and running with Application LoadBalancer
Tips:- While switching to Different servers change the pem file permissions every time to 400 e.g.:- chmod 400 keypair.pem
Terraform Installation Commands for Amazon-Linux:-
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform
terraform -v