Terraform — WordPress Stack on AWS EC2
Built a fully declarative Terraform configuration that provisions a WordPress stack on AWS from scratch — EC2 instance, security group rules and a cloud-init bootstrap that installs the web server, database and WordPress dependencies — finishing with a live public endpoint serving the WordPress installer.
Business value
For teams that spin up web environments regularly, this replaces manual console-driven setup with a single repeatable command, eliminating configuration drift between builds. Provisioning and application install collapse from hours of clicking into one terraform apply, and every resource is codified for audit, fast teardown and disaster recovery.
The problem
Standing up a WordPress server by hand means a long sequence of console steps and SSH commands: launch an instance, configure inbound rules, install packages, wire up a database and deploy the application — every run slightly different, every step a chance for a misconfigured rule or a missed dependency. The task was to express that entire build as code: a main.tf with the provider and EC2 resource, variables.tf for inputs, outputs.tf for runtime metadata and an embedded user data script, producing a successful WordPress installation reachable on a public endpoint with no manual intervention.
What I built
- 01
Structured the project as a standard Terraform layout — main.tf for the AWS provider and resources, variables.tf for inputs, and outputs.tf to expose instance details after apply.
- 02
Declared input variables for the instance type and security group name (t3.micro, WordPress-sg), making the configuration reusable across environments without editing the core code.
- 03
Provisioned an EC2 instance from an Amazon Linux AMI with an associated security group managing inbound HTTP and SSH traffic rules.
- 04
Automated the application layer with a user data / cloud-init script that bootstraps the instance at launch — installing the web server, MySQL and WordPress dependencies with zero manual SSH work.
- 05
Ran terraform apply to plan and create the resources, then iterated: changing the instance input forced a destroy-and-recreate, proving the configuration is the single source of truth.
- 06
Exposed the public endpoint dynamically through outputs.tf — instance ID, public/private IP, availability zone and instance type printed after every apply — and verified the live WordPress installer over the public IP.
Project stages
01 / 05
Stage 01 — terraform apply prompting for input variables (instance type t3.micro, security group name WordPress-sg) and generating the execution plan for the EC2 resource.