demo application
4640 "app" components
Included material
backend:
backend binary, hello-server service file for backend, hello-server.service
service file includes info about where the binary should be on your server
caddy file(this just exposes the backend on port 80), Caddyfile
frontend:
frontend, index.html nginx configuration file, hello.conf
The nginx configuration file needs to be edited
about the backend 'hello-server' exposes localhost:8080/echo This just echos back a post request message. An example curl command has been included for testing the backend. If everything is setup you will see your message echoed back to you.
Where should these files go
backend(hello-server) and frontend(index.html):
the files above provide the file paths (see service and nginx config)
Caddyfile /etc/caddy
hello-server.service /etc/systemd/system
Example curl commands for testing your server Replace the IP address in the examples with the IP address of your servers Run these commands from your host machine, not your server.
Testing your frontend
Testing your backend
curl -X POST -H "Content-Type: application/json"
-d '{"message": "Hello from your server"}'
http://146.190.12.184/echo
the link to the demo video : https://youtu.be/PcIiqDKu2Qw Sorry I missed the part for the ansible - so i recorded a very short video with the link: https://youtu.be/B6sd5_4ppdE
after downloading the zip file, Haniehsadat_gholamhosseini_as2.zip:
- in the main.tf inside the zip folder - comment the bucket configurations inside the terraform block on the top main.tf
as3 directory acts as terraform directory and as3-files-4640-w24 acts as my ansible directory
- run 'terraform init' to Prepare your working directory for other commands - so the backend.tf creates the s3 bucket and the dynamodb table to be prepred for the block that we just commented
- uncomment the bucket configuration inside the main.tf file in order to use AWS S3 for storing Terraform state files.
- run "terraform init" in your terminal or command prompt to initialize Terraform
- it asks for a permission - if its ok to move the tv state from writing it , type yes
- run 'terraform apply' to Create infrastructure (this will take a few minutes)
Once completed, clone the appliaction repository (https://gitlab.com/cit_4640/as3-files-4640-w24) I treated "as3-files-4640-w24" directory as my ansible - where my hosts.yml and ansible.config will be created in When Apply complete, will output ec2 instances public ip You should have hosts.yaml and ansible.config generated by terraform in the as3-files-4640-w24 directory located in same directory as main.tf.
- run cd '4640-assignment-app-files' where the application files and playbook are
- run 'ansible-playbook playbook.yml' to Run Ansible Playbook against the Infrastructure you just created
Once completed, do testing as instrcuction says in the README.md in the git repository as cloned in the same directory as main.tf in as3 directory