Skip to content

Commit

Permalink
Paginate DescribeImages depending on the boto3 version
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed Jul 4, 2024
1 parent a678a49 commit b063c14
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/module_utils/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,12 @@ def _is_missing(cls):
def describe_images(
client, **params: Dict[str, Union[List[str], bool, int, List[Dict[str, Union[str, List[str]]]]]]
) -> List[Dict[str, Any]]:
paginator = client.get_paginator("describe_images")
return paginator.paginate(**params).build_full_result()["Images"]
# 'DescribeImages' can be paginated depending on the boto3 version
if client.can_paginate("describe_images"):
paginator = client.get_paginator("describe_images")
return paginator.paginate(**params).build_full_result()["Images"]
else:
return client.describe_images(**params)["Images"]


@EC2ImageErrorHandler.list_error_handler("describe image attribute", {})
Expand Down

0 comments on commit b063c14

Please sign in to comment.