Deploying WordPress on AWS using EKS and RDS with Terraform

WordPress is a content management system generally used to host content like blogs on the internet.
WordPress requires the database to store the data. So, here we will use the database service provided by AWS that is the RDS(Relational Database Service).
To make this application more scalable, we will deploy this application on the Kubernetes. AWS provides Kubernetes as a service named as EKS(Elastic Kubernetes Services).

  1. To deploy a web app using EKS, we required the EKS cluster.
  2. To make the WordPress data and configuration persistent, we required persistent storage. Here we will use EFS(Elastic File Storage) for the persistent storage.
  3. WordPress docker image.
  4. Relational database RDS.

For creating EKS cluster and EFS storage refer to this article where I’d already shown how to configure them.

So, up till now, we had created an EKS cluster and created and configured an EFS storage to provide persistent storage to WordPress.

We will use Terraform(Infrastructure As Code) for creating and deploying WordPress and RDS.

The aws_db_instance module is used to create an RDS database. Here we are using MySQL version 5.6.

Finally, we are deploying WordPress on the EKS.

Use the following commands to run the Terraform code.

$ terraform init
$ terraform apply

Finally, the WordPress app is deployed in the EKS, and the RDS database is created.

To access the WordPress app we need to know the URL of the WordPress app. As we are using Kubernetes(EKS), we have to get the URL of the service.
Run the following command to get the URL of the WordPress app.

$ kubectl get all

Get the EXTERNAL-IP and open it in the browser.

As we are getting the WordPress installation screen, we had deployed WordPress correctly. Now, we have to configure and install WordPress and connect the database to it.

connecting database

After database connection is done, we just have to install WordPress. And after that are ready to create and publish our content to the public world.

Finally, we had launched our WordPress application of the EKS using RDS. This application is so scalable that we can scale it up and down according to the requirements and traffic to the app.

That’s it for this Article. I hope you had learned how to launch the WordPress web app on the AWS-EKS cluster and using the RDS database services by AWS.

If you liked this article, please applaud it.

You can also follow me on Twitter at @cankush625 or find me on LinkedIn.

Tech blogger, researcher and integrator