Skip to content

This project consists of creating a structure in AWS for a auto scaling application. It is made up of the following components: VPC, Internet Gateway, Subnets, Route Tables, Security Groups, Load Balancer, Auto Scaling Group, CloudWatch and RDS.

License

Notifications You must be signed in to change notification settings

diogofiaminghi/terraform-application-auto-scaling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-application-auto-scaling

5 min 16 sec for provisioning on AWS after 'terraform apply' command

GitHub language count Repository size GitHub last commit License Stargazers

Status: Finished

DescriptionPre-requisitesSolution ArchitectureHow it worksTech StackAuthorLicense

Description

This project consists of creating a structure in AWS for a auto scaling application. It is made up of the following components:

  • VPC
  • Internet Gateway
  • Subnets
  • Route Tables
  • Security Groups
  • Load Balancer
  • Auto Scaling Group
  • CloudWatch
  • RDS

Pre-requisites

Before you begin, you will need to have the following tools installed on your machine: [Terraform] (https://www.terraform.io/) and [Git] (https://git-scm.com). You will need to have a [AWS Account] (https://aws.amazon.com/). In addition, it is good to have an editor to work with the code like [VSCode] (https://code.visualstudio.com/).


Solution Architecture

Project-Diagram


How it works

1 - Clone this repository.

git clone git@github.com:diogofiaminghi/terraform-application-auto-scaling.git

2 - Open console AWS.

IMPORTANT: Make sure you are in "us-east-1" region

Project-Diagram


  • Go to EC2

Project-Diagram


  • Network & Security >> Key Pairs

Project-Diagram


  • Create Key Pair

Project-Diagram


  • Name = terraform-application-auto-scaling
  • Key pair type = RSA
  • Privete key format = .pem
  • Click on "Create key pair"

Project-Diagram


  • The key is downloaded automatically

Project-Diagram

IMPORTANT: Copy the key to the same project directory (keep your key in a safe place and don't share it. You will use it to access the instances).


  • Change permission.
chmod 400 terraform-application-auto-scaling.pem

3 - Add the key-name in your .gitignore file.

4 - You must now configure your AWS Access Keys using the bash terminal.

export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

5 - Terraform Commands in Project Folder

terraform init
terraform fmt
terraform validate
terraform plan -out=plan.out
terraform apply plan.out

6 - Now, to prove that everything worked, we will test the Auto Scaling.

  • AWS console >> EC2 >> Instances >> click on WEB instance >> monitoring >> CPU Utilization >> View in metrics >> periodo 10s >> auto-refresching 10s. Repit this for the second WEB instance in another browser tab.

  • In another browser tab, open Auto Scaling Grou >> Activity >> Activity history

  • In Load Balancer, copy the DNS name >> paste in another browser tab >> the html page must be loaded

  • connect via ssh to both web instances

ssh -i "terraform-application-auto-scaling.pem" ubuntu@the-public-ip-here
sudo stress-ng --cpu 32 --timeout 600 --metrics-brief
  • observe the number of instances being increased and decreased as stress rises and falls. The test will end in 10 minutes.

7 - Do not forget to destroy the provisioned structure otherwise you will be able to receive invoices.

terraform destroy

Tech Stack

The following tools were used in the construction of the project:


Author

Diogo Fiaminghi

Linkedin Badge Gmail Badge


License

This project is under the license MIT.

Made with love by Diogo Fiaminghi 👋🏽 Get in Touch!


About

This project consists of creating a structure in AWS for a auto scaling application. It is made up of the following components: VPC, Internet Gateway, Subnets, Route Tables, Security Groups, Load Balancer, Auto Scaling Group, CloudWatch and RDS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published