Launching VPC with NAT gateway for instance in the private subne
Firstly what is vpc and NAT gateway..?
VPC(Virtual private cloud)
The VPC is a boundary of AWS resources on the cloud and allows one to isolate their resources from other networks
and if we talk about NAT gateway,it is an appliance which is used to connect instances in your private subnet to the internet. So rather than exposing the private instances in the private subnet directly via the Internet gateway, all the traffic can be routed via the NAT gateway. Now one can also use the NAT instance to drive traffic from private instances.
lets start..!!
Firstly we gonna a folder on desktop and then our main file in it.
In command prompt #cd Desktop
#mkdir tera
#cd tera
#mkdir vpctask2_NAT
Also we have to configure AWS before starting
#notepad vpc.tf....now create following code in this file
Now as we created this file,further we have to download some plugins for it using below command
now we are finally ready to run this file and create whole setup in just one go by running one single command given here...
here we can see our setup is created
Instances running fine
VPC is also created
NAT Gateway is created also
for now to see our wordpress instance is working or not we can put public ip if wordpress instance on browser and can see our it runnning fine
Here we just have to login and give a unique paasword ,also username will remain aurora whatever be your password
And here we can create our blogs like this..
Now we gonna login to our bastion host to reach mysql instance..for this firstly copy its ip from GUI,after all this we gonna copy our key for mysql in bastion host using Winscp Program.
In above step we used winscp to copy key here like this
Finally we are ready to login to our mysql instance
Now we can do anything in mysql, as NAT gateway is given to it we can even download or update any software if we want to as we have done in above step.
Finally run #terraform destroy
This command will delete all your setup in just one go
..
..