Coder Social home page Coder Social logo

rproenza86 / elastic_load_balancing Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 4 KB

Elastic Load Balancing to load balance traffic across multiple EC2 instances in a multiple Availability Zones.

HCL 100.00%
aws terraform aws-ec2 aws-vpc aws-internet-gateway aws-subnet aws-route-table aws-security-group aws-load-balancer

elastic_load_balancing's Introduction

Elastic Load Balancing

Terraform scripts to build the AWS environment where to use Elastic Load Balancing to load balance traffic across multiple Amazon Elastic Compute Cloud (EC2) instances in a multiple Availability Zones. You will deploy a simple application on multiple Amazon EC2 instances and observe load balancing by viewing the application in your browser.

Tested using:

Terraform v0.11.10
+ provider.aws v1.42.0

Use case description

Launch a pair of instances, bootstrap them to install web servers and content, and then access the instances independently using Amazon EC2 DNS records.

Next, terraform will set up Elastic Load Balancing, add the EC2 instances to the load balancer, and then access the DNS record again to watch your requests load balance between servers.

Finally, you will be able of view Elastic Load Balancing metrics in Amazon CloudWatch.

Infrastructure objectives

  • Create Virtual Private Cloud(VPC)
  • Create a public and private subnets
  • Create an Internet Gateway
  • Create a Route Table and add a route to the Internet
  • Create a security group for the web server to only allow HTTP inbound traffic from Internet
  • Launching a multiple server web farm on Amazon EC2.
  • Using bootstrapping techniques to configure Linux instances with Apache, PHP, and a simple PHP application downloaded from Amazon Simple Storage Service (S3).
  • Creating and configuring an application load balancer that will sit in front of your Amazon EC2 web server instances.
  • Viewing Amazon CloudWatch metrics for the load balancer.

How to use

Pre-requirement: Set AWS environment variables

$ export TF_VAR_access_key=<your_key>

$ export TF_VAR_secret_key=<your-secret>

$ export TF_VAR_region=<your_region>

Initialize a working directory

$ cd intrastructure/

$ terraform init

Create an execution plan

$ terraform plan

Apply the changes required to reach the desired state of the configuration

$ terraform apply

Delete infrastructure

$ terraform destroy

How to test?

When applied the configuration terraform will show us the next output:

Outputs:

loadbalancer_public_dns_records = web-servers-lb-1880196268.us-east-1.elb.amazonaws.com
web_servers_public_dns_records = [
    ec2-35-173-28-26.compute-1.amazonaws.com,
    ec2-35-175-69-159.compute-1.amazonaws.com
]

Use the loadbalancer_public_dns_records to test multiple times the endpoint hitting both web servers.

elastic_load_balancing's People

Contributors

rproenza86 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.