Skip to content

Instantly share code, notes, and snippets.

@Jonty
Created March 18, 2020 18:20
Show Gist options
  • Save Jonty/f6edd5566e123d1910daed751b4c315c to your computer and use it in GitHub Desktop.
Save Jonty/f6edd5566e123d1910daed751b4c315c to your computer and use it in GitHub Desktop.
Grab autoscaling settings for all elastic beanstalk applications and environments
import boto3
eb = boto3.client("elasticbeanstalk")
asg = boto3.client("autoscaling")
response = eb.describe_environments()
instances = 0
for env in response["Environments"]:
resources = eb.describe_environment_resources(
EnvironmentName=env["EnvironmentName"]
)
groups = asg.describe_auto_scaling_groups(
AutoScalingGroupNames=[
a["Name"] for a in resources["EnvironmentResources"]["AutoScalingGroups"]
]
)
ms = "1 - NOT AUTOSCALING!"
ds = 1
gs = groups["AutoScalingGroups"]
if len(gs) > 0:
ms = groups["AutoScalingGroups"][0]["MinSize"]
ds = groups["AutoScalingGroups"][0]["DesiredCapacity"]
instances += ds
if ms != ds:
print(
env["ApplicationName"], env["EnvironmentName"], "Min:", ms, "Current:", ds
)
print("Total vm's: ", instances)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment