WordPress launch on Aws using terraform

WordPress launch on Aws using terraform

Hello Everyone!!

I am back with another project.

Install software- 1. Awscli (https://awscli.amazonaws.com/AWSCLIV2.msi.) 2.terraform (https://www.terraform.io/downloads.html)

Software version-

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


Description-

1.Firstly we have to create vpc.

2.Then in that vpc we have to launch two Subnets ->public subnet (Accessible for public World) ->private subnet (Accessible for private world)

3.Then we have to create a Public facing Internet Gateway to connect our VPC to the internet world and attach Internet gateway to the VPC.

4.Create Routing table for Internet gateway so that instance can connect to the outside world,connect that routing table with public subnet.

3.Then we have to create two Security group ->Security Group for WordPress(allow HTTP, SSH , ICMP ) ->Security Group for MySQL (allow MYSQL, ICMP)

4. Then we have to create two instance ->Instance for Wordpress (under public subnet) ->Instance for Mysql (under private subnet)

5.To launch wordpress with the IP of WordPress Instance.

Hope you understand the task so now we move towards task implementation

!!!SO LET'S START THE TASK!!!

So firstly create a folder in which you will download all the terraform plugin and run terraform code and launch different services.

so here I created a folder

>mkdir terra

>cd terra (inside terra folder another folder is created with name task)

>mkdir task

>cd task

No alt text provided for this image

Now configure aws by the credential you have downloaded while creating IAM user

No alt text provided for this image

Now download all the Terraform Plugin.

>terraform init

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

Step 1- Provider which will provide service from aws

No alt text provided for this image

Step 2- Now we will create vpc using terraform code. What is Vpc? Amazon Virtual Private Cloud (Amazon VPC) lets you provision a logically isolated section of the AWS Cloud where you can launch AWS resources in a virtual network that you define. ... You can use both IPv4 and IPv6 in your VPC for secure and easy access to resources and applications.

No alt text provided for this image


No alt text provided for this image

Step 3 - Now we have to create one public subnet. What is public subnet? If the subnet traffic routed to internet gateway it is know as Public subnet.We have created a Public subnet for wordpress site and given IPv4 IP range the name of IP is 10.0.0 and it range is from 0-24 (i.e any of the IP address given but the range of IP is fixed).Top 5 IP address are fixed for some services.map_public_ip_on_launch ="true" (It will automatically provide public IP.

IP OF PUBLIC SUBNET -10.0.0.0/24(Range 0-24)

No alt text provided for this image

Now create private subnet - What is Private Subnet? If a subnet dosn't have route to the internet gateway it is know as Private Subnet. We have created a Private subnet for mysql and given IPv4 IP range which should be in the VPC IP range. The name of IP is 10.0.1 and it range is from 0-24 (i.e any of the IP address given but the range of IP is fixed).Top 5 IP address are fixed for some services.

Note:-1.All Subnets have different IP name. All Subnets have different availability zone (disaster management)

IP OF PRIVATE SUBNET -10.0.1.0/24(Range 0-24)

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

Step 4 - Create an Internet Gateway. What is Internet Gateway?An internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the internet. Aninternet gateway supports IPv4 and IPv6 traffic. It does not cause availability risks or bandwidth constraints on your network traffic.

An internet gateway serves two purposes: to provide a target in your VPC route tables for internet-routable traffic, and to perform network address translation (NAT) for instances that have been assigned public IPv4 addresses.

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

Step 5- To create a route table. What is route table?A route table contains a set of rules, called routes, that are used to determine where network traffic from your subnet or gateway is directed. To put it simply, a route table tells network packets which way they need to go to get to their destination.Associate the route table with public subnet.

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

Step 6- Create Key pair and use that key to launch the instance.The name of my key is "vpc-key".

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

Step 7- Now we will create Two security group one for WORD PRESS and another one for MYSQL.

1.Security group for WordPress. It will allow some protocols like: ->HTTP ->SSH ->ICMP (for pinging).

No alt text provided for this image

->Same as we launch another security group for Mysql

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

Step 7 -To launch two EC2 INSTANCE

Wordpress instance- For this instance I have used WordPress Certified by Bitnami and Automattic.

No alt text provided for this image

Firstly I have launch this instance and then create one image using this instance.

No alt text provided for this image

Then using this created Image I have launch my wordpress instance and used this created image ami id.

No alt text provided for this image

Similarly launch Mysql instance.

No alt text provided for this image
Both the instance has been successfully launch.

Now we will launch WordPress.

So for that click on wordpress-os and then go to ->Actions ->Instance Setting ->Get system.

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

Here I highlight the password this is the password of your WordPress .Now using the Instance IP you can launch wordpress.

No alt text provided for this image

So in my case Instance IP is 13.234.231.149/wp-admin (to get login page of WordPress)

No alt text provided for this image

Here in username-user Password-*********** (from system log)

No alt text provided for this image

!!!SUCCESSFULLY LAUNCH WORDPRESS IN AWS CLOUD!!!

To run whole terraform code we use terraform apply command

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

Similarly to destroy the terraform code we use terraform destroy command.

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

SO Task 3 has done Successfully!!.

Hope You like it.

Thanks for reading the blog.

------------------------------------------------------------------------------------------------------------


Sejal Rathore

Software Engineer@Wells Fargo

4 年

Thanks MAYUKH B. ??

MAYUKH B.

Master's in CyberSecurity at SUTD #Fuzzing #Vulnerability Research #dynamic testing #SIEM #PEN TEST

4 年

Well done!!

Rupali Gurjar

Software Engineer II @Cvent | Tech Blogger | Aws-CSA | MLOPS | DEVOPS | Hybrid Multi Cloud | GCP | Ansible | Docker | Terraform

4 年

Good Job sejal !

回复

要查看或添加评论,请登录

Sejal Rathore的更多文章

  • GOOGLE CLOUD PLATFORM

    GOOGLE CLOUD PLATFORM

    What is GCP cloud ? Google cloud platform(GCP) it is the public cloud invented b google.This cloud provide us different…

    6 条评论
  • FLOWER AND FACE RECOGNITION USING VGG16

    FLOWER AND FACE RECOGNITION USING VGG16

    !!!HELLO EVERYONE!!! !!!HOPE YOU ALL ARE SAFE AND EMPOWERING YOUR TECHNICAL SKILLS!!! So today I am come with another…

    10 条评论
  • LAUNCH CONTAINER WITH DOCKERFILE CREATED IMAGE AND RUN WEB-PAGE ON IT USING JENKINS.

    LAUNCH CONTAINER WITH DOCKERFILE CREATED IMAGE AND RUN WEB-PAGE ON IT USING JENKINS.

    Hello Everyone!!Hope you all are safe and improving your technical skills. So here I explain how I implemented my task…

    6 条评论

社区洞察

其他会员也浏览了