deploy the Wordpress application on Kubernetes and AWS using terraform

Abhya Singh
3 min readSep 19, 2020

1. Write an Infrastructure as code using terraform, which automatically deploy the Wordpress application

2. On AWS, use RDS service for the relational database for Wordpress application.

3. Deploy the Wordpress as a container either on top of Minikube or EKS or Fargate service on AWS

4. The Wordpress application should be accessible from the public world if deployed on AWS or through workstation if deployed on Minikube.

provider “aws” {
region=”ap-south-1"
profile=”mavericks”
}

provider “kubernetes”{
config_context_cluster=”minikube”
}

resource “kubernetes_deployment” “test2”{
metadata{
name=”wordpress”
labels={
test=”wp”
}
}
spec{
replicas= 2
selector{
match_labels={
test=”wp”
}
}
template{
metadata{
labels={
test=”wp”
}
}
spec{
container{
image=”wordpress:4.8-apache”
name=”wordpress”
}
}
}
}
}

resource “kubernetes_service” “loadbalancer1”{
metadata{
name =”lb”
}
spec{
selector={
test=”wp”
}
port{
node_port=31000
port=80
target_port=80
}
type=”NodePort”
}
}

resource “aws_db_instance” “myrdsdb”{
allocated_storage=5
storage_type=”gp2"
engine=”mysql”
engine_version=”5.7"
instance_class=”db.t2.micro”
name=”RDS_db”
username=”ABHYA”
password=”Abhya944"
port=”3306"
parameter_group_name=”default.mysql5.7"
iam_database_authentication_enabled=true
publicly_accessible=true
skip_final_snapshot=true

tags={
name=”myrdsdb”
}
}

--

--

No responses yet