Setup WordPress with IaC

Let me share my real-time experience with working on typical requirement to setup WordPress on aws EC2 along with MySQL server as backend DB considering below asked…

1) Set up VPC with one subnet frontend and one backend subnet.

2) Open only required ports.

3) Configure NGNIX as load balancer on frontend subnet.

4) Install and configure PHP on frontend subnet.

5) Setup WordPress on frontend subnet along with data base configuration.

6) Setup MySQL on backend Subnet.

7) Ability to set up with single command.

8) Same script should run with other cloud provider with minimum changes.

Generally, to solve this type of requirement we go with two step process.

· First prepare required infrastructure.

· And then configure/Install required software.

But here need was to configure everything with single script from infrastructure setup to software/package installation with required configuration with single command!!

Now here we can think of using terraform or aws cloud formation to automate the infrastructure but considering the cloud vender locking we decided to go for terraform.

Before going deep to solution, Lets have quick look of Terraform.

Terraform is an open-source infrastructure as code software tool created by HashiCorp. Users define and provide data center infrastructure using a declarative configuration language known as HashiCorp

Typical Script to set up VPC with Subnets and Internet Gateway and Route Table along with EC2 machine.

Snapshot of Terraform Script

With this we will able to setup Infrastructure with Single command. But still we are addressing half requirement.

Now we wanted to see how deploy require software package along with configuration. That we will try to address in next article.

AWS Certified, Google Certified Professional Cloud Architect working on Cloud domain with multiple technology stack.