我使用这段代码从自动缩放组中分离实例
import os, subprocess
CMD = "aws autoscaling --region us-east-1 describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`Test_Tag_1`].Value,`SBX_Min_Det`)].Instances[*].[InstanceId]' --output text"
output = subprocess.check_output(CMD, shell=True)
lst = []
for char in output:
lst.append(char)
lst = ''.join(lst).split('\n')
lst.remove("")
print (lst)
for l in lst:
l = '"'+str(l)+'"'
new_cmd = "aws autoscaling --region us-east-1 detach-instances --auto-scaling-group-name Test_Group --should-decrement-desired-capacity --instance-ids "+l
subprocess.check_output(new_cmd, shell=True)
但是,我希望能够使用一个脚本从多个组中分离多个实例。我对Python和awscli命令非常陌生。任何帮助都将不胜感激。谢谢。在
我对之前的脚本做了一些修改,如下所示,目前仍停留在这里。在
^{pr2}$
amazonec2自动伸缩组可用于根据需要自动提供多个amazonec2实例。在
例如,当入口繁忙时,扩展策略可以自动启动其他实例(“向外扩展”)。然后,在夜间,当实例未被充分利用时,自动缩放可以自动移除实例(“扩展”)。在
自动缩放还监视自动缩放组中实例的运行状况,并将自动替换任何失败的实例。在
这是通过指定一个启动配置来完成的,该配置定义了如何启动一个新实例,包括实例类型、AMI和安全组。在
Types of scaling包括:
Dynamic Scaling for Amazon EC2 Auto Scaling - Amazon EC2 Auto Scaling可通过以下方式控制:
最简单的方法是使用Target Tracking Scaling Policies for Amazon EC2 Auto Scaling:
底线:您应该而不是将实例分离并附加到自动缩放组。相反,您应该根据指定的指标(例如CPU利用率、用户数量、工作积压工作等)配置伸缩策略,使之自动发生。在
请注意,自动缩放会启动新实例或终止实例。它会启动/停止实例。在
相关问题 更多 >
编程相关推荐