Use NAT Gateway for Internet Connectivity and Launch WordPress Application with Mysql
Completed Task !!!. In this task, we have to perform task -3 with an additional feature to be added that is NAT Gateway to provide the internet access to instances running in the private subnet.
We have to create Infrastructure like this:
Following steps to be performed:
1- Write an Infrastructure as code using terraform, which automatically create vpc.
2- In that VPC we have to create two subnets : a) Public subnet b) Private subnet
3- Create a public facing Internet gateway for connect or VPC/Network to the internet world and attach this gateway to our VPC.
4- Create a routing table for Internet gateway so that instance can connect to outside world , update and associate it with public subnet.
5- Create a NAT gateway for connect our VPC/Network to the Internet world and attach this gateway to our VPC in the public network.
6- Update the routing table of the private subnet, so that to access the internet it uses the NAT gateway created in the public subnet.
7- Launch an EC2 instance which has wordpress setup already having the security group allowing port 80 so that our client can connect to our wordpress site. Also attach the key to instance for further login into it.
8- Launch an EC2 instance which has Mysql setup already with security group allowing port 3306 in private subnet so that our wordpress instance can connect with the same . Also attach the key with the same.
* First we have to choose AWS as a provider
* then we create our own VPC.Don't forget to enable DNS hostname
* In that VPC we have to create two subnets:-- public subnet and private subnet. And in public subnet don't forget to enable public IP.
* then we create internet gateway for connect our vpc to internet world and attach this gateway to our vpc.
* we have to create a routing table so that our instance can connect to outside world and associate it with public subnet.
* Create a NAT gateway for connect our VPC/Network to the internet world and attach this gateway to our VPC in the public network.
* Create a routing table for private subnet , so it uses NAT gateway for access internet.
* Create security group for wordpress application which allowing port 80 so that our client can connect to our wordpress site. And create key which can attach to instance for login into it.
* Launch an EC2 instance in public subnet which has wordpress setup and attach key to instance.
* Create security group for Mysql database which allowing port 3306. So that our wordpress instance can connect with the same .
* Launch an EC2 instance in private subnet which has Mysql setup and attach created key with the same.
* For build this terraform code run following commands:-
1.- terraform init-- for installation of required plugins
2.- terraform apply -- to create this Infrastructure
3- terraform destroy -- to destroy this Infrastructure
THANKS!!! FOR READING