mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #8503 from jsmartin/fix_ec2_asg_delete
ec2_asg: Implements the proper method for terminating an auto scale group.
This commit is contained in:
commit
c2231e429a
1 changed files with 9 additions and 7 deletions
|
@ -283,15 +283,17 @@ def delete_autoscaling_group(connection, module):
|
|||
groups = connection.get_all_groups(names=[group_name])
|
||||
if groups:
|
||||
group = groups[0]
|
||||
group.shutdown_instances()
|
||||
|
||||
group.max_size = 0
|
||||
group.min_size = 0
|
||||
group.desired_capacity = 0
|
||||
group.update()
|
||||
instances = True
|
||||
while instances:
|
||||
groups = connection.get_all_groups()
|
||||
for group in groups:
|
||||
if group.name == group_name:
|
||||
if not group.instances:
|
||||
instances = False
|
||||
tmp_groups = connection.get_all_groups(names=[group_name])
|
||||
if tmp_groups:
|
||||
tmp_group = tmp_groups[0]
|
||||
if not tmp_group.instances:
|
||||
instances = False
|
||||
time.sleep(10)
|
||||
|
||||
group.delete()
|
||||
|
|
Loading…
Reference in a new issue