Launching VPC  with NAT gateway for instance in the private subne

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

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Now as we created this file,further we have to download some plugins for it using below command

No alt text provided for this image




now we are finally ready to run this file and create whole setup in just one go by running one single command given here...

No alt text provided for this image





here we can see our setup is created

Instances running fine

No alt text provided for this image

VPC is also created

No alt text provided for this image

NAT Gateway is created also

No alt text provided for this image

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

No alt text provided for this image

Here we just have to login and give a unique paasword ,also username will remain aurora whatever be your password

No alt text provided for this image
No alt text provided for this image

And here we can create our blogs like this..

No alt text provided for this image

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.

No alt text provided for this image
No alt text provided for this image

In above step we used winscp to copy key here like this

No alt text provided for this image

Finally we are ready to login to our mysql instance

No alt text provided for this image
No alt text provided for this image

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

No alt text provided for this image

..

..

Thankyou




要查看或添加评论,请登录

Mahima Jindal的更多文章

社区洞察

其他会员也浏览了