How to create wordpress site on AWS using terraform | Technical EJ - Latest Technology News

Thursday 20 August 2020

How to create wordpress site on AWS using terraform

  Ekansh Jain       Thursday 20 August 2020

Hey Guys, today I am going to show you how to create a WordPress site on AWS with terraform tool.

Task-3) Statement: We have to create a web portal for our company with all the security as much as possible.

So, we use the WordPress software with a dedicated database server.

The database should not be accessible from the outside world for security purposes.

We only need the public WordPress for clients.

So here are the steps for proper understanding!

Steps:

1) Write an Infrastructure as code using Terraform, which automatically creates 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 to 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 the outside world, update and associate it with the public subnet.

5) Launch an ec2 instance that 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 the instance for further login into it.

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

Also, attach the key with the same.

Note: 

  1. WordPress instance has to be part of the public subnet so that our client can connect our site. 
  2. MySQL instance has to be part of a private subnet so that the outside world can't connect to it.
  3. Don't forget to add auto IP assign and auto DNS name assignment options to be enabled.
  4. Try each step first manually and write Terraform code for the same.
  5. This will give u a proper understanding of the workflow of tasks and the task is complete. 

Solution of Task-3

1) First, we are going to create a VPC. So that I can launch my instance on it.

launching vpc
launching vpc



output of launching PVC
output of launching PVC

2) Now we are going to create two subnets one is for public access and another one is for private purposes.

two subnets creation


output of two subnets


3) Now we are going to launch two instances, first is for the public subnet and another one is for the private subnet.

launching one instance in private subnet

Note: The above image shows to launch a "web" instance in the private subnet.

launching one instance in public subnet

Note: The above image shows to launch a "web1" instance in the public subnet.

web and web1 instances

4) Now we are going to create a public-facing internet gateway to connect our VPC/Network to the internet world and attach this gateway to our VPC.

creating internet gateway and attach with pre-created vpc


internet gateway created

Note: The above image shows that the internet gateway created.

5) Create a routing table for Internet gateway so that instance can connect to the outside world, update and associate it with the public subnet.

routing table creation


output of successfully created routing table

Note: The above image shows that the routing table created and has access to the public world.


6) Now we already created a WordPress setup instance(web1) already. Now we are allowing security groups for port 80 so that our client can connect to our WordPress site.

security group for public access

Note: The above image shows the security group for allowing public access.

7) Now we already created MYSQL setup instance(web) with a security group allowing port 3306 in a private subnet so that our WordPress VM can connect with the same.


security group for private access

output of security groups

Note: The above image shows the output of security groups.

Now using putty we can access the WordPress setup instance and we can easily do an ssh and we can ping google.

Here's the output of my blog:

 
That's it till now we successfully launch the WordPress site.


logoblog

Thanks for reading How to create wordpress site on AWS using terraform

Previous
« Prev Post

No comments:

Post a Comment

If you have any doubts, Please Comment down