Using Terraform and Ansible, this web application displays any RDS-injected student name and student ID on a web page.
Flask project files are sourced from my former professor's GitHub here
A simple, full-stack web application fully provisioned using Terraform Modules for the infrastructure and an Ansible Playbook for Host server setups.
REQUIRED STEPS:
- copy the directory using
cp -r /local/machine/path/to/my/project /dest/path- do NOT use
sudo!! - if terraform complains about having no permissions, try
sudo chmod 777 -Ron the project directory aftercp- THIS SPECIFIC INSTANCE OF
sudoLEADS TO PROBLEMS LATER!! (see step 4) ...refrain from doing it!!
- THIS SPECIFIC INSTANCE OF
- do NOT use
- cd to
backend_setup- run
terraform init - run
terraform apply --auto-approve
- run
- cd to
infra- run
terraform init - run
terraform apply --auto-approve
- this takes a while because of RDS, please be patient!!
- run
- cd to
service- run
ansible-playbook setup.yaml
- if you ended up running it as
sudo, the playbook will complain and say that it won't:- recognize ansible.cfg
- fail to see hosts in inventory
I am unsure what causes this other than
sudoand the ansible directory is too "open" as such
- run
- visit web DNS to view webapp
- found as an output of step 3 above
- you should see my full name and student ID when visiting the site!
CLEANUP:
- cd to
infra- run
terraform destroy - enter
yes
- this takes a while because of RDS, please be patient!!
- run
- cd to
backend_setup- run
terraform destroy - enter
yes
- run
NOTES:
- this project assumes you have the following:
- ssh key at
~/.ssh/acit_4640 - ssh key
acit_4640in AWS EC2- us-west-2 (US West Oregon)
- home IP address (/16) OR range (/24)
- configurable in
./infra/terraform.tfvarsonline 10
- configurable in
- student name and student ID
- configurable in
./service/roles/data_injection/tasks/main.yamlonline 56 namehas a character limit of30bcit_idhas a character limit of10
- configurable in
- ssh key at
The creation of the infrastructure consists of the following AWS resources separated by Modules:
- S3 Bucket
- RDS
- VPC
- Subnets
- Route Table
- Security Groups
- EC2 Instances
The configuration of the host servers from a dynamic host inventory consists of 4 roles—each with appropriate handlers—in a single Ansible Playbook:
| Role | Description |
|---|---|
| be | Installs backend and python dependencies for Backend Host, clones Flask project files, configures MYSQL to RDS Host, and creates and starts a new Service |
| data_injection | Installs database dependencies for Backend Host, creates database / user / table, and injects student data to RDS Host |
| tools | Installs base dependencies for Backend and Web Hosts |
| web | Installs web dependencies for Web Host, configures NGiNX proxy, clones Flask project files, and serves index.html |
- Amazon Web Services - cloud solution for web application
- Ansible - provisioning automation solution for Host servers
- DynamoDB - data storage solution
- Flask - framework for web application provided by former professor
- HTML - language used for web development
- Terraform - provisioning automation for infrastructure

