Browse the Repo

file-type-icon.circleci
file-type-iconexamples
file-type-iconmodules
file-type-iconasg-rolling-deploy
file-type-iconserver-group
file-type-iconrolling-deploy
file-type-iconboto3-1.7.10.zip
file-type-iconhelpers.py
file-type-iconrolling_deployment.py
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
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-iconmodules
file-type-iconasg-rolling-deploy
file-type-iconserver-group
file-type-iconrolling-deploy
file-type-iconboto3-1.7.10.zip
file-type-iconhelpers.py
file-type-iconrolling_deployment.py
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
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 (stateful)

Auto Scaling Group (stateful)

Run an Auto Scaling Group for stateful apps. Supports zero-downtime, rolling deployment, auto healing, IAM Roles, EBS Volumes, and ENIs.

Code Preview

Preview the Code

mobile file icon

rolling_deployment.py

down
  • import argparse
  • import helpers
  • import os
  • import time
  • from threading import Thread
  • LAUNCH_CONFIG_TAG_NAME = 'LaunchConfigName'
  • def run():
  • """
  • The main entrypoint for this script. It parses CLI arguments and kicks off a rolling deployment.
  • """
  • parser = argparse.ArgumentParser(description='Perform a rolling deployment of a server group.')
  • parser.add_argument('--aws-region', help='The AWS region to use.', required=True)
  • parser.add_argument('--server-group-size', help='The number of servers in the server group.', required=True, type=int)
  • parser.add_argument('--server-group-name', help='The name of the server group. This should stay the same across all deployments.', required=True)
  • parser.add_argument('--launch-config-name', help='The name of the Launch Configuration. This should change for each deployment.', required=True)
  • parser.add_argument('--alb-target-group-arns', help='The ARN of an ALB Target Group to use for health checks.', nargs='*')
  • parser.add_argument('--elb-names', help='The name of an ELB to use for health checks.', nargs='*')
  • parser.add_argument('--batch-size', help='The number of servers to redeploy at a time.', type=int, default=helpers.DEFAULT_BATCH_SIZE)
  • parser.add_argument('--max-retries', help='Maximum number of times to retry checking.', type=int, default=helpers.DEFAULT_MAX_RETRIES)
  • parser.add_argument('--retry-interval-sec', help='How long to wait between each health check in seconds.', type=int, default=helpers.DEFAULT_SLEEP_BETWEEN_RETRIES_SEC)

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?