Git Product home page Git Product logo

terraform_aws_alb_asg's Introduction

Inspiration

Inspiration for this repo was a couple of YouTube tutorials from Java Home Cloud where it was demonstrated how to create AWS Application Load Balancers and Auto Scaling groups.

Java Home Cloud - AWS Application Load Balancer Java Home Cloud - AWS Auto Scaling group

Assumption

This is not a beginner's guide to learning Terraform or AWS. It is assumed the reader is already familier with these technologies and would instead like to find related topics like ASG and LB in one place for reference purpose.

Scope

I wanted to take a step further and automate the video instructions. The idea is that setting up of the infrastructure should be automated without human intervention.

This includes using Terraform Registry modules for creating:

  • Virtual Private Cloud (VPC) that host the entire infrastructure in this repo.
  • VPC is subdivided in four subnets; two are public and two are private
  • Application Load Balancer (ALB) in public subnets
  • Network Load Balancer (NLB) in public subnets
    • Code has been written but commented out for the following reasons:
      • NLB target groups appear to delete ALB target groups
      • For NLB to work alongside ALB, ASG security will need to be open from the entire world e.g. 0.0.0.0/0. And so, I did not want to open security group so widely
  • Classic ELB (ELB) in public subnets
  • Auto Scaling Group (ASG) in private subnets and are only reachable via LB on port 80
  • Auto Scaling policies for scaling up / down instances based on CloudWatch CPU alarms raised
  • Security groups that only allow traffic on port 80 to EC2 instances via LB

Create infrastructure

This is how infrastrucutre is setup with Terraform:

  • terraform init
  • terraform apply -auto-approve

Test

  • Classic ELB and ALB were created above. Use DNS records for each of the LB for testing.
  • Refreshing the pages should return different result depending which ASG the LB routed traffic to.

Destroy infrastructure

This is how the infrastructure created above may be destroyed if it is no longer needed

  • terraform destroy -auto-approve

Reference

terraform_aws_alb_asg's People

Contributors

shazchaudhry avatar

Watchers

 avatar  avatar

terraform_aws_alb_asg's Issues

Create Auto Scaling group

  • All traffic from ALB for "payments" go to payments target group
  • All traffic from ALB for "orders" go to orders target group

Create a VPC

A VPC is needed where all network resources will be created

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.