Browse the Repo

file-type-icon.circleci
file-type-iconexamples
file-type-iconmodules
file-type-iconasg-rolling-deploy
file-type-icondescribe-autoscaling-group
file-type-iconREADME.md
file-type-iconboto3-1.7.10.zip
file-type-iconget-desired-capacity.py
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
file-type-iconserver-group
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-icondescribe-autoscaling-group
file-type-iconREADME.md
file-type-iconboto3-1.7.10.zip
file-type-iconget-desired-capacity.py
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvars.tf
file-type-iconserver-group
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

get-desired-capacity.py

down
  • from __future__ import print_function
  • import zipfile
  • import tempfile
  • import os
  • import logging
  • import time
  • import json
  • logging.basicConfig()
  • logger = logging.getLogger()
  • logger.setLevel(logging.INFO)
  • # We can't run boto3 directly from a zip file, so we have to extract it: https://github.com/boto/boto3/issues/749
  • current_dir = os.path.dirname(os.path.realpath(__file__))
  • boto3_src = os.path.join(current_dir, 'boto3-1.7.10.zip')
  • boto3_dest = os.path.join(tempfile.gettempdir(), 'boto3-1.7.10')
  • boto3_init = os.path.join(boto3_dest, "boto3", "__init__.py")
  • # Code below taken from: https://stackoverflow.com/a/12468091/991958
  • # We may have a race condition extracting the zip archive below if several
  • # processes try to extract it at the same time. Try to catch the
  • # concurrency issue and swallow the exception and just retry rather than dealing
  • # with cross OS locking.
  • while True:

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?