AWS NaaS Using Terraform For Secure WordPress Deployment

Ayush Kumar singh
3 min readJul 19, 2020

--

What We’ll Do ??

We will create a web portal for our company with all the security as much as possible. We will be using WordPress software with a dedicated database server i.e. MySQL Server. This database should not be accessible from the outside world for security purposes. Only WordPress Site Should be Public To The World.

How We’ll Do ??

  1. We’ll Create a VPC For Our Web Portal.
  2. In that VPC we have to create 2 subnets:

-Public Subnet [ Accessible for Public World! ]

-Private Subnet [ Restricted for Public World! ]

3. Create a public-facing internet gateway and attach it to our VPC.

4. Create a routing table for the Internet gateway and associate it with the public subnet.

5. Create a Security Group For WordPress And Will Allow Port 80 And Allow World to Access it.

6. Another Security Group For SQL Which Only Allow 3306 Port From WordPress Security Group Only.

7. Launch WordPress Instance with Public Subnet, Security Group And MySQL Instance With Private Subnet, Security Group.

Let Do it!

We’ll Use Not Use Web Console, We’ll Go with Terraform i.e IaC.

Now, What Is TerraForm?

It an open-source infrastructure as a code software tool created by HashiCorp. It enables users to define and provision a data centre infrastructure using a high-level configuration language known as Hashicorp Configuration Language.

Terraform can manage existing and popular cloud service providers(AWS, AZURE, GCP, Alibaba) as well as custom in-house solutions.

Lets Code! {All My Code Is Available Here}

Before Coding We Need to Authenticate it To Our AWS!

  1. Creating VPC {A Virtual Private Cloud lets you provision a logically isolated section of the AWS Cloud }

2. Creating 2 Subnets

{ A subnet, or subnetwork, is a network inside a network Through sub-netting, network traffic can travel a shorter distance without passing through unnecessary routers to reach its destination }

3. Creating Internet Gateway And Attaching to Our VPC

{An Internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between instances in your VPC and the Internet. }

4. Creating Routing Table And Associating it with Public Subnet

{ 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. }

5. Creating a Security Group For WordPress & Allowing World to Access

6. Creating a Security Group For MySQL & Allowing Only Our WordPress to Access it.

7. Let's launch Our WordPress And MySQL Instance Using This VPC And Subnets!

Done !!

All Above Code Is Available On My GITHUB : Here

Thanks, EveryOne For Reading My Blog!

My LinkedIn : bit.ly/ayushlinkedin

--

--

No responses yet