Deploying an Application using VPC,NAT Gateway and Internet Gateway

Deploying an Application using VPC,NAT Gateway and Internet Gateway

Our requirement is to create a web portal for our company with all the security.So,we need to use WordPress with dedicated DB Server.In our case,Database should be provided the Internet Connectivity and should be created in Private Subnet.Also,we need to public WordPress for our clients and should be created in Public Subnet

For performing this,we need-

1-AWS Account for using its services

Use this link to create AWS Account:- https://aws.amazon.com/

2-Terraform package for using terraform command

Use this link for downloading Terraform:- https://www.terraform.io/downloads.html

For this purpose,perform following tasks-

1-After downloading Terraform,provide the Path to it.

No alt text provided for this image

2-Select Environment Variables and then click to Path and write the Path of terraform in it.

No alt text provided for this image

3-Now,check by typing terraform version in command prompt.

No alt text provided for this image

4-Now,we have to create a Terraform Code for performing our task.First,we have to specify AWS as a provider.

No alt text provided for this image

5-Now,we will create a VPC

No alt text provided for this image

6-Now,we will create 2 subnets ie. first one will be public(for WordPress) and the other one will be private(for MYSQL)

No alt text provided for this image

7-Now,we will create an Internet Gateway to connect our VPC to the outside world ie. Internet

No alt text provided for this image

8-Now,create a routing table for Internet Gateway so that instance can connect to outside world.

No alt text provided for this image

9-Now,associate Internet Gateway with public subnet

No alt text provided for this image

10-Now,create a NAT Gateway and provide it with Internet Connectivity along with its Elastic IP

No alt text provided for this image

11-Now,create a routing table for NAT Gateway and associate it with private subnet

No alt text provided for this image

12-Now,create key pair for WordPress and MYSQL ie, public and private

No alt text provided for this image

13-Now,create Security Group for WordPress

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

14-Now,create Security Group for MYSQL

No alt text provided for this image

15-Launch the WordPress instance using the above security group

No alt text provided for this image

16-Launch the MYSQL instance using the above security group

No alt text provided for this image

17-Now,just print the Public IP of WordPress instance on command prompt

No alt text provided for this image

18-Now,type following commands in command prompt-

terraform init #Downloads AWS plugins internally

No alt text provided for this image

terraform validate #Validates the terraform code

No alt text provided for this image

terraform plan #Displays the resources which will be created by our code

No alt text provided for this image

terraform apply -auto-approve

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

Thats's All!!

Our whole infrastructure is launched in AWS Cloud.We can see the resources running in AWS Console

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,if we type the Public IP of WordPress in our browser-

No alt text provided for this image

Thank You!!









To view or add a comment, sign in

More articles by Nilesh Mathur

Others also viewed

Explore content categories