Deploying WordPress with AWS RDS

In this blog i will be deploying WordPress with Amazon RDS ( Relational Database Service ) using Terraform to automate on AWS Cloud.

Why RDS ?

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security and compatibility they need.

Why Terraform ?

Terraform solves the issue of provisioning complicated infrastructure — bringing together worlds of multiple cloud providers — ranging from multi-purpose giants like AWS to one-solution providers.

Now before proceeding further there are some requirements you need :

Necessary Requirements:

Now in this blog i will be performing below tasks:

Below are the steps how you can successfully execute my code:

Step 1: Configure your aws profile with below cmd

aws configure

Step 2: Now below will be steps for code completion. If you are not interested then you may skip to Step 3.

# AWS Providerprovider "aws" {
region = "ap-south-1"
profile = "apeksh"

That’s it for coding part. Now execution part resumes

Step 3: Go inside directory where your terraform files are present and run

terraform init

It will install all the necessary plugins for your code.

Step 4: Now run

terraform apply --auto-approve

It will take some time to complete and then after it will do all the thing for you. You can verify from your AWS console also .

Step 5: Now go to Public IP of your WEB instance in EC2 or you can also get from publicIP.txt
You will see the WordPress installation page like this

Fill your Database details as mentioned under RDS instance in file.
Note: In database host copy the host address from DB_host.txt file

Step 6: This is one of the main step. Now you will be redirected to this page. Then copy the entire text and you have to copy this into your ec2 instance.

So SSH into the instance either from Putty or from Browser connect of AWS.

Then use below commands

sudo su
cd /var/www/html/
cp wp-config-sample.php wp-config.php
vim wp-config.php

Now just edit your database details as shown below.

Now click on Run the Installation after editing.

Step 7: If you get this page that means you have successfully configured WordPress.
Now enter your details and login into WordPress.

That’s it for installation part.

Now you can create website or blog and publish it.

Step 8: For removing all your setup use command

terraform destroy

then it will prompt to say yes, enter yes to delete your whole setup in one go.

That’s it for our project.

Now one of major advantage of AWS RDS is it provides visual metrics for your database and is flexible which is very handy to use.

Github repo:

Thanks all of you for reading. See you in next blog



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store