Hello folks!
🏁 Our scenario for today is creating a multi-tier architecture with WordPress in the Front End and MySQL DB in the backend, also the Internet Facing Website should be in a public subnet with connectivity with the outside world and the DB Server is isolated from the outside world situated in a private subnet with connectivity only with the WordPress Instance.
We shall not be looking into What is IAC and Terraform, as it was already covered in the previous blog, if you haven't yet please give it a read - https://dev.to/rajitpaul/high-availity-architecture-setup-on-aws-using-terraform-402b
📍 First, off we will start by creating a VPC, with two subnets ( public & private ) followed by an internet gateway created and attached with the vpc, next we shall create a route table and add routes into it also associating it to the public subnet.
📍Next, we shall create a key pair and two security groups one acting as our custom sg for the ec2 instance we shall launch later and another acting as a default vpc sg.
📍Finally, we shall launch an ec2 instance in the public subnet also create a db-instance powered by AWS RDS in the private subnet.
#terraform plan
#terraform validate
#terraform apply
Our Infrastructure is halfway!
📍Now we shall be cloning a git repo in our ec2-instance and running a py script to set up the WordPress on EC2,
GitHub Repo - https://github.com/AWS-Cloud-Community-LPU/Scripts-For-Webinar.git
We shall be taking the help of terraform null resource, connection, and remote-exec provisioner for this purpose!
Once the terraform script is successfully executed we shall have WordPress deployed on EC2
Now we shall be fetching all the details from RDS such as DBname, User, Password & Endpoint and populate that on WordPress installation and this shall be generating a wp-config.php file which we shall copy to the WordPress dir on EC2 instance, for that we shall SSH to the EC2 Instance
Our Multi Tier Infrastructure is deployed, let us create our first blog
Code- https://github.com/RajitPaul11/terraform_aws/tree/main/Multi-Tier-Architecture_Vpc
<--->
Multi-Tier-Architecture using NAT GW
image credits:https://symbols.getvecta.com/
Adding a Nat Gateway to the architecture so that the DB Instance can connect to the Internet.
The NAT Gateway sits on the public subnet and acts as a one-way gateway to the Internet for our Database Instance.
Code- https://github.com/RajitPaul11/terraform_aws/tree/main/Multi-Tier-Arch-VPC-NATGW
⚡⚡Thanks for Reading⚡⚡
Top comments (0)