This terraform projects creates RDS databse with mysql 5.7 #EC2 instance with wordpress pre installed and configured
Change database entries ,regions and other variable in terraform.tfvars file And Database password in user.tfvars file
This script is only suitable for AWS LINUX 2 so make sure you have correct region and ami id in that region.
Make sure you have configured aws CLI in your local machine Ansible is installed in your local machine playbook_test.yml is a ansible script for LINUX 2
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
<----------------------------------------------------------------------------------------------------------------------->
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
Ansible should be installed in youn local machine.
Configure AWS CLI with aws configure
if you havent configured already
<------------------------------------------------------------------------------------------------------------------------>
Clone this repo using command git clone https://github.com/devbhusal/terraform-ansible-wordpress.git
Go to project folder cd terraform-ansible-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 -var-file="user.tfvars"
Apply the plan using terraform apply -var-file="user.tfvars"
After successfull provisioning of AWS Resources,Using remote-exec and private key, EC2 instance will be connected via SSH. Yum will be updated and Python will be installed so that local ansible server can communicate with the provisoned EC2 . Once Installation is done ,Using local exec , Ansible playbook will be run against provisioned EC2
everything is Automatic. This will provision all needed aws resources and also build and start webserver using Ansible
Destroy the resources terraform destroy -var-file="user.tfvars"