Commit 25c65a6e by Kevin Falcone

We bumped past 50 ASGs

You can set MaxRecords to 100 but this will just fail again when we get
there.  botocore has a builtin paginator for most API calls, so I just
wrapped that up and appended to matching_groups.
parent dac68385
......@@ -41,8 +41,14 @@ class ActiveInventory():
asg = session.create_client('autoscaling',self.region)
ec2 = session.create_client('ec2',self.region)
groups = asg.describe_auto_scaling_groups()
matching_groups = [g for g in groups['AutoScalingGroups'] for t in g['Tags'] if t['Key'] == 'Name' and t['Value'] == asg_name]
asg_paginator = asg.get_paginator('describe_auto_scaling_groups')
asg_iterator = asg_paginator.paginate()
matching_groups = []
for groups in asg_iterator:
for g in groups['AutoScalingGroups']:
for t in g['Tags']:
if t['Key'] == 'Name' and t['Value'] == asg_name:
matching_groups.append(g)
groups_to_instances = {group['AutoScalingGroupName']: [instance['InstanceId'] for instance in group['Instances']] for group in matching_groups}
instances_to_groups = {instance['InstanceId']: group['AutoScalingGroupName'] for group in matching_groups for instance in group['Instances'] }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment