AWS EKS with WordPress and RDS Complete Configuration Using Terraform Only

Ayush Kumar singh
2 min readSep 7, 2020

Amazon Elastic Kubernetes Service (Amazon EKS) is a fully managed Kubernetes service. EKS is deeply integrated with services such as Amazon CloudWatch, Auto Scaling Groups, AWS Identity and Access Management (IAM), and Amazon Virtual Private Cloud (VPC), providing you with a seamless experience to monitor, scale, and load-balance your applications.

Overview

♦️ Creating an EKS Cluster with IAM roles, VPC, Security Grp…

♦️ Updating the kubeconfig file

♦️ Creating an RDS instance with MySQL Database

♦️ Launching WordPress with Loadbalance service and RDS as Database

For These, We’ll Only Use Terraform.

Let's Go!

For Clear Understanding, I have Divided all the Task into Different .tf(Terraform) files.

All Files are Available On My Github: Here

1. VPC File:

>>It Creates 1 VPC, 2 Subnet, Internet gateway and a Routing table attached with Internet gateway and associated with both the subnet.

2. EKS-Cluster File:

>>It first creates an IAM Role to allow EKS service to manage other AWS services. A security Group attracted our VPC and allow 443(https) and Creates an EKS-Cluster.

3. EKS-Worker-node File:

>>Creates IAM role allowing Kubernetes actions to access other AWS services and A EKS Node Group with 2 nodes with AMI AL2_x86_64 and t2.micro attracted with key for ssh.

4. RDS File:

>> It Creates a Database Instance of MySQL with username and password. These Credentials are stored in Var.tf file.

5. Update KubeConfig File:

>> This File Will update The Kube Configuration File with AWS EKS Cluster.

6. Kubernetes Configuration File:

>> It Creates a PVC For Our Deployment and then Deploys a WordPress Container linked with RDS as Database and has a LoadBlancer Service Exposed at port 80.

Rest of the Files are Dependencies of Each Other.

Let Run Them!

  1. “Terraform init” → this will install requiered Plugins
  2. “Terraform Plan” → To Check Resources to be Created.
  3. “Terraform apply” → Execute Every Task.

Note: We have to run Terraform apply 3 times. Why → We are Dealing with 3 Different Providers at a time and all are dependent on Each other.i.e EKS on AWS, update Config on localhost and Kubernetes. After 3rd Run, our Setup will be ready.

Done!!

Thanks For reading Hope it helps!

Any Suggestion or Query. Ping Me

LinkedIn: Here

GitHub Repo: Here

--

--