boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
8.81k stars 1.84k forks source link

CloudControl Boto list_resources call for API Gateway API Keys returns max 25 resources #4166

Closed lreeder-arpio closed 1 week ago

lreeder-arpio commented 1 week ago

Describe the bug

When using the Boto CloudControl API to list API gateway keys (TypeName AWS::ApiGateway::ApiKey), only 25 resources are returned even though the account contains many more and the MaxResults argument is 100. In addition, the paginator only returns one page with 25 resources

Expected Behavior

When given TypeName=AWS::ApiGateway::ApiKey and MaxItems=100, list_resources API call should return 100 resources or all the resources in the account, whichever is less.

Current Behavior

When given TypeName=AWS::ApiGateway::ApiKey and MaxItems=100, list_resources API call only returns 25 resources, even though more are in the account.

Reproduction Steps

    cc_client = boto3.client('cloudcontrol', region_name=region)
    # max allowed for MaxResults is 100
    resp = cc_client.list_resources(TypeName='AWS::ApiGateway::ApiKey', MaxResults=100)
    resp_str = json.dumps(resp, indent=4, default=str)
    print(resp_str)
    total_count = len(resp['ResourceDescriptions'])
    print(f'Total item count: {total_count}')

Total item count is 25, and only 25 items are returned

Alternatively, use pagination to list the API keys:

    paginate_args = {'TypeName': 'AWS::ApiGateway::ApiKey'}

    paginate_args['PaginationConfig'] = {
        'MaxItems': 100
    }

    paginator = cc_client.get_paginator('list_resources')
    n = 1
    total_count = 0
    for page in paginator.paginate(**paginate_args):
        rd_count = len(page['ResourceDescriptions'])
        total_count = total_count + rd_count
        print(f'###############Page {n}: {rd_count} Resource Descriptions###############')

        n = n + 1
        resp_str = json.dumps(page, indent=4, default=str)
        print(resp_str)

    print(f'Total item count: {total_count}')

Only one page with 25 resources are returned.

Possible Solution

No response

Additional Information/Context

Tested in us-east-1

The API Gateway Boto API call get_api_keys does work correctly and returns all API keys.

SDK version used

Boto3 1.28.66

Environment details (OS name and version, etc.)

Linux 5.15.0-107-generic, Python 3.11.7

tim-finnigan commented 1 week ago

Thanks for reporting this issue. I could reproduce the behavior you described, also in the JS SDK as well. This issue therefore resides in the underlying ListResources API so we will need to escalate this to the Cloud Control team. I created a new issue for this in our cross-SDK repository to track going forward: https://github.com/aws/aws-sdk/issues/764. Please refer to that issue for updates, and thanks again for bringing this to our attention.

github-actions[bot] commented 1 week ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.