Web Platform Using VPC

Statement: We have to create a web portal for our company with all the security as much as possible. So, we use Wordpress software with dedicated database server.Database should not be accessible from the outside world for security purposes.We only need to public the WordPress to clients.

So here are the steps for proper understanding!

Steps:

1) Write a Infrastructure as code using terraform, which automatically create a VPC.

2) In that VPC we have to create 2 subnets:

a) public subnet [ Accessible for Public World! ] b) private subnet [ Restricted for Public World! ]

3) Create a public facing internet gateway for connect our 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) 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.

6) Launch an ec2 instance which has MYSQL setup already with security group allowing port 3306 in private subnet so that our wordpress vm can connect with the same.

Also attach the key with the same.

Let’s Write Terraform Code : )

First We have to do authentication between Terraform and AWS . So here we use our Profile .

Let’s Create a Public Subnet . I am going to create this subnet in the VPC that I created so I have to provide id of the VPC . I create this subnet in ap-south-1a . Here I give size of /24 CIDR so that it provides 256 private ip’s to this Subnet .

We will launch our Web portal in one of its instance . For outside connectivity we have to assign public ip to the instance . For this I enable auto assigning of Public IP

Now create a private Subnet . I create this subnet in ap-south-1b and give CIDR cidr_block = “192.168.1.0/24”

To create Internet gateway , we have to provide ID of VPC .

Here we have to add some Route so that everyone can connect to instance using Internet Gateway .

First we create a key and Security Group .

For creating key , I use RSA Algorithm . It will provide a public key .

In the Security Group , I added two rule first for ssh that allow port no 22 and second for HTTP that allow port No 80 .

Now write code for instance .

To launch this instance , I use an AMI having WORD- PRESS so that we can create a Web-Portal . I launch this instance in public subnet . To login I attach the key that I created . Also add the security group .

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store