When making calls to AWS EC2 api with DescribeTags actiion and if the number of filter values is greater than or equal to 200, it results in 400 bad request reply and the error message is: "Error connecting to AWS backend.\n The maximum number of filter values specified on a single call is 200". The change is so that we call get_all_tags with maximum 199 filter values one at a time until all are consumed.
This commit is contained in:
parent
9273e1e7c7
commit
3498b840c9
1 changed files with 6 additions and 1 deletions
|
@ -527,7 +527,12 @@ class Ec2Inventory(object):
|
|||
instance_ids = []
|
||||
for reservation in reservations:
|
||||
instance_ids.extend([instance.id for instance in reservation.instances])
|
||||
tags = conn.get_all_tags(filters={'resource-type': 'instance', 'resource-id': instance_ids})
|
||||
|
||||
max_filter_value = 199
|
||||
tags = []
|
||||
for i in range(0, len(instance_ids), max_filter_value):
|
||||
tags.extend(conn.get_all_tags(filters={'resource-type': 'instance', 'resource-id': instance_ids[i:i+max_filter_value]}))
|
||||
|
||||
tags_by_instance_id = defaultdict(dict)
|
||||
for tag in tags:
|
||||
tags_by_instance_id[tag.res_id][tag.name] = tag.value
|
||||
|
|
Loading…
Reference in a new issue