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-
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
Now configure aws by the credential you have downloaded while creating IAM user
Now download all the Terraform Plugin.
>terraform init
Step 1- Provider which will provide service from aws
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.
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)
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)
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.
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.
Step 6- Create Key pair and use that key to launch the instance.The name of my key is "vpc-key".
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).
->Same as we launch another security group for Mysql
Step 7 -To launch two EC2 INSTANCE
Wordpress instance- For this instance I have used WordPress Certified by Bitnami and Automattic.
Firstly I have launch this instance and then create one image using this instance.
Then using this created Image I have launch my wordpress instance and used this created image ami id.
Similarly launch Mysql instance.
Now we will launch WordPress.
So for that click on wordpress-os and then go to ->Actions ->Instance Setting ->Get system.
Here I highlight the password this is the password of your WordPress .Now using the Instance IP you can launch wordpress.
So in my case Instance IP is 13.234.231.149/wp-admin (to get login page of WordPress)
Here in username-user Password-*********** (from system log)
!!!SUCCESSFULLY LAUNCH WORDPRESS IN AWS CLOUD!!!
To run whole terraform code we use terraform apply command
Similarly to destroy the terraform code we use terraform destroy command.
SO Task 3 has done Successfully!!.
Hope You like it.
Thanks for reading the blog.
------------------------------------------------------------------------------------------------------------
Software Engineer@Wells Fargo
4 年Thanks MAYUKH B. ??
Master's in CyberSecurity at SUTD #Fuzzing #Vulnerability Research #dynamic testing #SIEM #PEN TEST
4 年Well done!!
Software Engineer II @Cvent | Tech Blogger | Aws-CSA | MLOPS | DEVOPS | Hybrid Multi Cloud | GCP | Ansible | Docker | Terraform
4 年Good Job sejal !