-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CloudControl API Returns More Items Than Specified by MaxResults #9314
Comments
Hi @shalev007 , thanks for reaching out. AFAIU, you are confusing the Max_Results with total number of results returned. What you are mentioning is this parameter which is the number of resources returned per page (i.e.100) and the total resources are 1000. So if there are more than the specified limit of Max_results, paginations keeps the next_token to iterate to next page - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudcontrol/list-resources.html
This article explains how pagination works in AWS CLI-https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html Hope that should help clarify. Let me know if there are any questions. Thanks. |
@khushail, I'm not sure how this solve the problem, but I'm sure @shalev007 ultimately wants to know how to effectively limit the number of resources returned from a call made to Secondly, You highlighted in your comment that
Testing with a resource like SQS, the NextToken parameter is not present in the output to facilitate pagination even if the And I have 1500 queues in the region, only 1000 was returned, since the NextToken was not in the response, the remaining 500 was never retrieved... |
The AWS CLI docs clearly mention this - https://docs.aws.amazon.com/cli/latest/reference/ram/list-resources.html
which means You should be able to get the next-token the first time you got the output and you would need to mention the next command with this next-token.s @mk-armah , what value did you use for the |
similar to what @shalev007 shared, I just made few changes to communicate the issue being experienced specifically with SQS import aioboto3
import asyncio
async def validate_list_resources(kind, max_results, region, profile):
session = aioboto3.Session(profile_name = profile, region_name=region)
params = {
"TypeName": kind,
"MaxResults": max_results
}
async with session.client('cloudcontrol') as client:
response = await client.list_resources(**params)
resources = response.get('ResourceDescriptions', [])
print(f"Number of resources returned: {len(resources)}")
if len(resources) > max_results:
print("Error: More resources returned than specified in MaxResults!")
else:
print("Validation successful: The number of resources is within the MaxResults limit.")
next_token = response.get('NextToken')
if next_token:
print("Additional pages available. NextToken:", next_token)
else:
print("No additional pages; this is the full page of results.")
if __name__ == "__main__":
max_results_value = 100
kind = "AWS::SQS::Queue"
profile = "default"
region="us-east-1"
asyncio.run(validate_list_resources(kind, max_results_value, region, profile)) Response: (.venv) chael@Michaels-MacBook-Pro aws % python test.py
Number of resources returned: 1000
Error: More resources returned than specified in MaxResults!
No additional pages; this is the full page of results.
(.venv) chael@Michaels-MacBook-Pro aws %
same can be reproduced with the CLI using this command, the command below returns null indicating there is no NextToken aws cloudcontrol list-resources \
--type-name "AWS::SQS::Queue" \
--region us-east-1 \
--max-results 100 \
| jq -r '.NextToken'
null while |
@mk-armah , thanks for sharing the details. I found some internal tickets and github issue references filed by my team which are already addressing the issue with this
Looks like this |
Thank you for making it clear that the MaxResults is reserved and not yet supported,
|
MaxResults has varying degrees of functionality depending on the service resource between listed. For SQS, do you have enough queues that they aren't all being listed in the first call?
Since it appears that pagination is just generally not working for CloudControl ListResources, the only workaround would be to use SQS ListQueues. |
Yes I have 1500+ in one region and only get 1000 when I make the first call ..
Thank you!
|
CloudControl is definitely aware of this behavior and the limitations of the API. They specifically documented MaxResults as "Reserved", so I have to assume this is planned work. I have no promises on the timeline for implementation though.
I wouldn't recommend relying on this operation to do pagination correctly until they fully implement MaxResults. |
Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one. |
Describe the bug
When using the CloudControl API with the MaxResults parameter, the API returns more items than specified. For example, setting MaxResults to 100 results in 1000 items being returned overall. This behavior is confusing, as it appears that the API should only return up to the specified number per page.
Regression Issue
Expected Behavior
The MaxResults parameter should strictly limit the number of items returned in a single API call to the value specified
Current Behavior
The MaxResults parameter seems to be ignored
Reproduction Steps
aws cloudcontrol list-resources --type-name AWS::S3::Bucket --max-results 1
MaxResults
Possible Solution
No response
Additional Information/Context
I saw it was mentioned in the docs https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/API_ListResources.html#API_ListResources_RequestSyntax, but as reserved, is it wrong to make use of it?
CLI version used
aws-cli/2.24.5 Python/3.12.9 Darwin/24.3.0 source/arm64
Environment details (OS name and version, etc.)
MacOS Sequoia 15.3.1
The text was updated successfully, but these errors were encountered: