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.
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,
)