this repo is an example of using ELB
Elastic Load Balancing with ASG
Auto Scaling Group to provide highly available and efficient Nodejs Apps
we will use ASG
to launch a cluster
of EC2
Instances, monitoring the health of each Instance, replacing failed Instances, and adjusting the size of the cluster in response to load.
ASG
distributes theEC2
instances across multipleavailability zones
- each
AWS account
has access to different set ofAvailability zones
, in this repo, i've choosedall
availability zones available in my account
- each
after deploying the ASG
you'll have several different servers, each with its own ip address, but you need to give your end users only a single IP to hit, and for this we're going to deploy a load balancer to distribute traffic accross your servers and to give your end users a single dns name which is the the load balancer dns name
For other platforms to install Terraform download the binray from the download page
https://www.terraform.io/downloads.html
yum -y install unzip
cd /tmp
wget https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip
unzip terraform_0.11.7_linux_amd64.zip -d /usr/bin/
terraform -v
Insert your AWS access key
& secret key
as Environment Variables, In this way we're NOT setting them permanently, you'll need to run these commands again whenever you reopen your terminal
export AWS_ACCESS_KEY_ID=<your access key>
export AWS_SECRET_ACCESS_KEY=<your secret key>
yum -y install git
git clone https://github.com/Eslam-Naser/terraform-AWS-ASG-ELB.git
cd terraform-AWS-ASG-ELB/
# Downloading the Plugin for the AWS provider
terraform init
- See what's terraform is planning to do before really doing it
terraform plan
- build the terraform project
terraform apply
# yes | if you want to proceed
<public IPv4>:5000/api/v1.0/task
- destroy what you've built
terraform destroy
# yes | if you want to proceed