A common scenario includes an Amazon RDS DB instance in an Amazon VPC, that shares data with a Web server that is running in the same VPC. In this repo a VPC for this scenario is created. The following diagram shows this scenario
Inspriration for this repo came from this tutorial; Create a Web Server and an Amazon RDS Database.
This solution has been tested on CentOS 7.4:
- You may use the provided Vagrantfile for testing the solution locally if you like
- Not tested on Windows but as per the documentation here you will need to use Pageant as an SSH authentication agent
This repository uses AWS provided modules from Terraform Module Registry
- You have installed Terraform version which is >= 0.11.8
- You are using CentOS 7.4
- .PEM key is available under: "~/.ssh/". In my case it is called personal.pem
- AWS credentials are available at "~/.aws/credentials" which should look like as follows:
[default]
aws_access_key_id = <KEY>
aws_secret_access_key = <SECRET>
Please follow the instructions below to stand up Apache HTTPD + MySQL in AWS using Terraform:
eval $(ssh-agent)
ssh-add -k ~/.ssh/personal.pem
ssh-add -k ~/.ssh/id_rsa
git clone git@github.com:shazChaudhry/terraform-WebAppWithRDS.git && cd terraform-WebAppWithRDS
terraform init
terraform plan
terraform apply -auto-approve
- In your favorite web browser, navigate to http://YOUR_EC2_WEBSERVER/calldb.php (you will need to check AWS console for the instance IP address)
- Refresh the page a few time and note that number of rows will be incremented
terraform show
terraform destroy -force