简体   繁体   中英

How can I dynamically observe/change limits of a Autoscale group?

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.

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 .

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM