Author: Abaasi
GitHub: [Abaasi256]
LinkedIn: https://www.linkedin.com/in/abaasi-k-b79420340
This project demonstrates how to deploy a WordPress application on AWS using Terraform and CI/CD Pipeline. The infrastructure includes:
- EC2 Instance: Hosts the WordPress application with PHP 8.x and Apache.
- RDS MySQL Database: Stores WordPress data.
- VPC, Subnets, and Security Groups: Secure and isolate the resources.
- Auto-Assign Public IP: Ensures the EC2 instance is accessible over the internet.
Below is the architectural diagram of the deployment:
Description: Diagram of architectural diagram
Infrastructure.
- Infrastructure as Code: Automated provisioning using Terraform.
- Scalable WordPress Deployment: EC2 instance with PHP 8.x and Apache.
- Secure Database: RDS MySQL database with multi-AZ support.
- Public Access: Auto-assign public IP for the EC2 instance.
- AWS Account: Ensure you have an AWS account with sufficient permissions.
- Terraform Installed: Download and install Terraform from here.
- AWS CLI Installed: Install the AWS CLI and configure it with
aws configure
. - SSH Key Pair: Create an SSH key pair in AWS or use an existing one.
This project includes a GitHub Actions workflow to automate Terraform validation and deployment. The pipeline performs the following steps:
- Terraform Init: Initializes the Terraform configuration.
- Terraform Validate: Validates the Terraform configuration.
- Terraform Plan: Generates an execution plan.
- Terraform Apply: Applies the Terraform configuration (only on the
main
branch).
To use the pipeline:
- Add your AWS credentials as GitHub Secrets (
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
). - Push changes to the
main
branch to trigger the pipeline.
- Clone this repository:
git clone https://github.com/abaasi256/terraform-wordpress-deployment.git cd terraform-wordpress-deployment
- Update the
terraform.tfvars
file with your AWS credentials and configuration:aws_region = "us-east-1" ami_id = "ami-0c02fb55956c7d316" # Replace with a valid AMI ID for your region instance_type = "t2.micro" key_name = "your-key-pair-name" db_name = "wordpressdb" db_user = "admin" db_password = "your-strong-password" availability_zone = "us-east-1a"
- Initialize and apply the Terraform configuration:
terraform init terraform plan terraform apply
- Access the WordPress application:
- Open a web browser and navigate to:
http://<EC2-Public-IP>
- Complete the WordPress installation wizard.
- Open a web browser and navigate to:
- EC2 Instance Public IP:
terraform output wordpress_instance_public_ip
- RDS Endpoint:
terraform output rds_endpoint
To destroy the infrastructure:
terraform destroy
Here are some suggested screenshots for your project:
Description: Output of terraform apply
after successfully deploying the infrastructure.
Description: WordPress installation page accessed via the EC2 instance's public IP.
Description: EC2 instance in the AWS Management Console, showing the public IP and running state.
Description: RDS database in the AWS Management Console, showing the endpoint and status.
- Abaasi: Project author and maintainer.
Hi, I'm Abaasi, a cloud and DevOps enthusiast passionate about automating infrastructure using Terraform. This project is a reflection of my skills and expertise in AWS and Infrastructure as Code (IaC). Connect with me on LinkedIn or check out my other projects on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.