Auto Creating Web portal on Cloud by creating VPC

Snehalhingane
5 min readJul 15, 2020

--

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.

Step1: Adding the Provider and Profile.

A provider is responsible for understanding API interactions and exposing resources.

provider + profile

Step2: Create VPC(Amazon Virtual Private Cloud)

Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you’ve defined. This virtual network closely resembles a traditional network that you’d operate in your own data center, with the benefits of using the scalable infrastructure of AWS.

VPC
Creation of VPC

Step3: Create Subnet:

Subnet is a basically logical subdivision of an IP network.Amazon VPC supports IPv4 and IPv6 addressing, and has different CIDR block size quotas for each. By default, all VPCs and subnets must have IPv4 CIDR blocks — you can’t change this behavior.

When you create a VPC, you must specify an IPv4 CIDR block for the VPC. The allowed block size is between a /16 netmask (65,536 IP addresses) and /28 netmask (16 IP addresses). After you've created your VPC, you can associate secondary CIDR blocks with the VPC.

subnet

step 3:Create a public facing internet gateway for connect our VPC/Network to the internet world and attach this gateway to our VPC.

A gateway is a node (router) in a computer network, a key stopping point for data on its way to or from other networks.

For basic Internet connections at home, the gateway is the Internet Service Provider that gives access to the entire Internet.

internet Gateway

Creating a Route Table

A routing table contains a set of rules, called routes, that are used to determine where network traffic from your subnet or gateway is directed.

Rrouting table

Associating the Routing Table

Associating the Routing Table

step 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.

  • Create key pair for wordpress
key pair
  • Create Security Groups for wordpress
security Group

Launch an ec2 instance for wordpress

EC2 instance for wordpress

Create security group for mysql

security group for mysql

Launch an ec2 instance for MYSQL

ec2 instance

Now your script is ready. Run this script & everything is set up automatically for you.

terraform init

terraform apply -auto-approve

To delete everything

terraform destroy -auto-approve

Final output:

terraform init
terraform apply
VPC
private Subnet + public Subnet
internet gateway
ec2 instance of wordpress + mysql

Thanks for Reading!!!!!!!!

Snehal B. Hingane

Under Guidance of : Vimal Daga sir and preeti mam

--

--

No responses yet