Home > Software engineering >  How can I dynamically observe/change limits of a Autoscale group?
How can I dynamically observe/change limits of a Autoscale group?

Time:01-05

I want to modify the number of minimum/maximum/target instances of an autoscale group and see if there's any instance on from this autoscale group, all dynamically using the AWS SDK for Python. How can I do it?

I'm unable to find it from literature.

CodePudding user response:

I will help you by pointing out where you can find informaton about using AutoScaling and the AWS SDK for Python. Refer to the AWS SDK Code Examples Code Library.

enter image description here

This doc should be the reference point when you want to learn how to do tasks using a given AWS SDK.

See:

https://docs.aws.amazon.com/code-library/latest/ug/auto-scaling_example_auto-scaling_Scenario_GroupsAndInstances_section.html

CodePudding user response:

First verify your time is sync with aws:

sudo ntpdate pool.ntp.org

Read configuration:

import boto3

client = boto3.client('autoscaling')

response = client.describe_auto_scaling_groups(
    AutoScalingGroupNames=[
        'autoscaling_group_name',
    ]
)

print(response['AutoScalingGroups'][0]['MinSize'], response['AutoScalingGroups'][0]['MaxSize'], response['AutoScalingGroups'][0]['DesiredCapacity'], response['AutoScalingGroups'][0]['Instances'])

Set desired/min/max:

response = client.update_auto_scaling_group(
    AutoScalingGroupName='autoscaling_group_name',
    MinSize=123,
MaxSize=123,
DesiredCapacity=123,
)
  • Related