3 Tier Architecture AWS best practices: WordPress application

Wordpress on AWS - Terraform for multiple teams Project

In this project, we aimed to build a three-tier WordPress application using Terraform in a real-world environment where the DevOps team is distributed worldwide and independent contributors or groups provide each block. To make it possible we use a "remote" backend for Terraform on an S3 bucket (versioning enabled) and DynamoDB to keep the state locked for only one transaction at a time.


  • 1 x S3 bucket (prod env)

  • 1 x DynamoDB table

  • 1 x VPC

  • 2 x Private Subnets

  • 2 x Public Subnets

  • 1 x Public Route table

  • 1 x Private Route table

  • 1 x Internet Gateway

  • 2 x NAT Gateway

  • 1 x Application Load Balancer

  • 1 x Auto Scaling Group (2 minimum 99 maximum instances-horizontally scalable)

  • 1 x security group for Web layer

  • 2 x EC2 instances (minimum) (WordPress)

  • 1 x RDS Aurora cluster with 1 writer, 1 reader instances (horizontally scalable)

  • 1 x security group for Database layer

Steps:

  1. Git clone the repo

  2. Go to repo directory:

  1. Check if aws s3 is available:

  1. Copy content from the "template.txt" file or edit and save it as "envs/prod/prod.tfvars" file:

  1. Run script to install Terraform environment and version:

Backend Setup (DynamoDB +S3)

Run Makefile:

Script also will create the "backend.tf" file into VPC,ASG,RDS folders

  1. Optionally, if your VM does not have administrator priviliages, run below commands to add your AWS credentials as environment variables.

  1. Finaly, run

And wait for about 20 mins

For Deleting Resources and delete the Application:

TROUBLESHOOTING:

In case of error when deleteing S3 bucket use AWS console and manually empty and delete the bucket

Test Database accessibility:

From EC2 instance of Web in your VPC!!! DB endpoints should be available from the final outputs

You should see:

Last updated