/terraform-ec2-RDS-wordpress

Create Wordpress site in EC2 with database RDS

Primary LanguageHCL

This terraform projects creates RDS databse with mysql 5.7 #EC2 instance with wordpress pre installed and configured

AWS FREE TRIAL friendly

Change database entries ,regions and other variable in terraform.tfvars file And Database password in user.tfvars file

This script is default for Ubuntu
If you want to configure wordpress in AWS LINUX 2 then change IsUbuntu value to false in terraform.tfvars

Make sure you have configured aws CLI in your local machine

user_data.tf is script for LINUX 2 and userdata_ubuntu.tpl is for Ubuntu

ami-id will be imported using data.aws_ami

Security:

EC2 will be launched in public subnet and RDS will be launched in private subnet

Only EC2 with defined security group can access RDS and RDS wont have internet access

Password for RDS will be used to create the resource, later it should be changed manually for security purposes. Terraform will ignore any changes in password

<----------------------------------------------------------------------------------------------------------------------->

Prerequisite

Before launching Terraform template, aws cli should be installed and configured with proper access key and secret key

Terraform should be installed in your local machine

Configure AWS CLI with aws configure if you havent configured already

<------------------------------------------------------------------------------------------------------------------------>

STEPS:

Clone this repo using command git clone https://github.com/devbhusal/terraform-ec2-RDS-wordpress.git

Go to project folder cd terraform-ec2-RDS-wordpress

Initialize terraform terraform init

Change database and aws setting in terraform.tfvars file

Generate Key pair using ssh-keygen -f mykey-pair

View Plan using terraform plan

Apply the plan using terraform apply

After successfull provisioning of AWS Resources,Using remote-exec and private key, EC2 instance will be connected via SSH. Tail command will used to check prgress of Wordpress Installation. Once Installation is done ,You will be provided with Public Ip address of WebServer.

everything is Automatic. This will provision all needed aws resources and also build and start webserver using USERDATA

Destroy the resources terraform destroy