itglue-assessment
Prerequisites
- Terraform 0.12
- Docker (needed to build the app container)
- aws-cli (for new deployments of app)
- terminal with AWS Admin Access credentials (Important)
- One functional VPC in your AWS account.
Instructions
-
In the
/infrafolder, runterraform init. This will initialize the folder with a terraform state. -
In the same folder, run
terraform apply -var 'vpc-id=<vpc_id>'where <vpc_id> is the id of your VPC w/o brackets. When prompted, type yes. There should be 34 resource additions.
Terminal should now show whether the stack creation has succeeded.
-
Outputs will contain the results/resources from stack creation. In the outputs, find this line:
lb_dns = <endpoint to app>Copy the value of that key and paste it in the browser. You will be directed to the app.
(For the sake of the assessment, deployment is simplified to one single deployment script. This deploy script is automatically generated with the correct repository name and ecs cluster/service name in
/app/deploy-script.sh) -
Test the app and verify it works. At first, it may still show
503 Service Unavailablebecause the tasks still needed to be registered as targets on the load balancer. Give this 2 minutes. -
To make updates, navigate to
/appfolder. Make appropriate changes toapp.jsorDockerfile, then executedeploy-script.sh. It will take up to 2 minutes for the live app to reflect those changes.
You can run terraform state list in /infra folder to see exactly what AWS resources have been created. Subsequently, running terraform state show <rsc_id> (where rsc_id is the id listed in the previous command) shows you details about the created AWS resources
Cleanup
To cleanup the app & stack, you will need to first empty the bucket. Use this command
aws s3 rm s3://<bucket-name> --recursive
bucket-name is provided in the outputs of the stack ran earlier.
This file is NOT run automatically as part of the stack. This is to simulate importance of S3 objects and preventing them from getting deleted.
Then, you can clean-up the stack. In /infra folder, execute
terraform destroy -var 'vpc-id=<vpc_id>'
where <vpc_id> is the id of your VPC w/o brackets. This can take up to 10 mins as Terraform needs to remove a few gateway resources in vpc.