Browse the Repo

file-type-icon.circleci
file-type-iconexamples
file-type-iconasg-rolling-deploy
file-type-iconwith-elb
file-type-iconwithout-elb
file-type-iconREADME.md
file-type-iconserver-group
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE.txt
file-type-iconREADME.md

Browse the Repo

file-type-icon.circleci
file-type-iconexamples
file-type-iconasg-rolling-deploy
file-type-iconwith-elb
file-type-iconwithout-elb
file-type-iconREADME.md
file-type-iconserver-group
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE.txt
file-type-iconREADME.md
Auto Scaling Group (stateless)

Auto Scaling Group (stateless)

Run an Auto Scaling Group for stateless apps. Supports zero-downtime, rolling deployment, auto healing, auto scaling, and IAM Roles.

Code Preview

Preview the Code

mobile file icon

README.md

down

Auto Scaling Group with Rolling Deploy Examples

This folder shows examples of how to use the asg-rolling-deploy module to create an Auto Scaling Group (ASG) that supports rolling deployment:

  • with-elb: An example of how to deploy an ASG where each instance registers with an Elastic Load Balancer (ELB).
  • without-elb: An example of how to deploy an ASG without any load balancer.

On each EC2 Instance in the ASG, for demonstration and testing purposes, we run a dummy web server that just returns "Hello World". If you update this app (e.g. change the text to "Hello, World v2" or replace the app with a totally different AMI of your own), the next time you run terraform apply, the new version of the app will roll out automatically, with no downtime, across your ASG.

How do you run these examples?

  1. Install Terraform.
  2. Make sure you have Python installed (version 2.x) and in your PATH.
  3. Open vars.tf, set the environment variables specified at the top of the file, and fill in any other variables that don't have a default.
  4. Run terraform get.
  5. Run terraform plan.
  6. If the plan looks good, run terraform apply.

Deploying a new version

Once you have the app up and running, to test out the rolling deployment, make a change to any of the variables passed into the ASG. For example, as a quick test, you could change the server_text variable to "Hello, World, v2.0!". Once you've made your changes, do the following:

  1. Commit your changes to Git so your teammates have access to them.
  2. Run terraform plan.
  3. If the plan looks good, run terraform apply.

The new version of the app will automatically deploy across the Auto Scaling Cluster. Under the hood, this is done by taking advantage of Terraform's create_before_destroy lifecycle property. This is the same strategy used by HashiCorp for it's own rolling deployments, as as described by Paul Hinze here.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?