The repository demonstrates a two-tier static web application hosting and configuration solution designed and implemented by group 15 of NAA batch.
The goal of this project is to create a two-tier static web application hosting and configuration solution utilizing source control, deployment automation and configuration management technologies. The project also assesses technical proficiency in Terraform, Load Balancers, Auto Scaling Groups in scalable cloud architecture, AWS identity and access management and the efficient use of git source control along with Github Actions to automate security scanning.
- Terraform
- Terragrunt
- Github Actions
- Github pre commits
- Load Balancers
- Auto Scaling Group
- Scaling Policies
This repo defines Git pre-commit hooks intended for use with pre-commit. The currently supported hooks are:
- terraform-fmt: Automatically run
terraform fmt
on all Terraform code (*.tf
files). - terraform-validate: Automatically run
terraform validate
on all Terraform code (*.tf
files). - detect-aws-credentials: Detects if any keys are present in the repository
Clone the repository to your local environment of Cloud9
git clone git@github.com:nisalikularatne/ACS_Group_15_FinalProject.git
In your AWS console in EC2 service under key pairs create one individual key for each environment
dev environment - acs-project-dev
staging environment - acs-project-staging
production environment - acs-project-prod
In the AWS portal under the S3 service create 3 buckets with the naming as shown below:
dev-acs730-finalproject-group15-bucket
staging-acs730-finalproject-group15-bucket
prod-acs730-finalproject-group15-bucket
The images in s3 bucket will be added using the terraform code. There is an images folder under launchTemplate inside the project which will be copied into the S3 bucket on terraform apply command.
In case you are unable to create a bucket if the name of the bucket exists in S3, an update to the bucket name in config.tf must be done inside the project along with the variable "bucket_name" default should be changed in each environment. In the case of image updation, the image names must be changed in the install_httpd.sh.tpl
We have created the following modules
- network
- securityGroup
- launchTemplate
- targetGroup
- applicationLoadBalancer
- autoScalingGroup
- scalingPolicies
- bastionHost
In order to deploy the infrastructure, deploy the above mentioned resources in the same order in 3 environments as mentioned below The Project folder will be using the files for each environment (dev, staging, prod)
Inside of the ACS_Group_15_FinalProject
cd Project/dev
alias tf=terraform
tf init
tf fmt
tf validate
tf plan
tf apply
Inside of the ACS_Group_15_FinalProject
cd Project/staging
alias tf=terraform
tf init
tf plan
tf apply
Inside of the ACS_Group_15_FinalProject
cd Project/prod
alias tf=terraform
tf init
tf plan
tf apply
In order to make the deployment faster we have integrated terragrunt.hcl files which will rapidly deploy the infrastructure in all 3 environments using the commands below. Run this command in the root of the project in CLI. This applies to all resources in dev, staging and prod
terragrunt run-all init
terragrunt run-all apply
In order to destroy the resources reverse the order of the resources mentioned above and follow the following command. Do it for all the resouces under Project (dev, staging and prod)
tf destroy
For destroying using terragrunt do the below:
terragrunt run-all destroy