-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
aws sqs list-queues returns incomplete result #8160
Comments
I just discovered if I run this:
AWS CLI gives the following error:
So it seems "no-paginate" has been hard coded? |
Hi @captainfalcon23 thanks for reaching out. It looks like the ListQueues API only returns a maximum of 1000 results: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ListQueues.html
It notes that in the CLI documentation as well:
Can you use |
Thanks for the reply. Yep, I did see that in the documentation, but my expectation is that AWS CLI is going to perform the pagination and get ALL the results by using the NextToken. Please see my comment below my original post. There are a few issues:
I quote from the S3 example I mentioned - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/list-objects-v2.html:
and
In the case of S3api, we can clearly see that it is making multiple API requests to get the full results. This is an example from one of my test buckets:
So - this issue is about the fact that the behaviour between the two AWS CLI commands is different, even though the behaviour of the underlying AWS API is the same (returns a max of 1000 results. |
Hi @captainfalcon23 thanks for following up. That error you mentioned was also reported in #2555, with this comment offering an explanation on that. Also for more context here is the CLI documentation on pagination: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html There are inconsistencies between service APIs but we don’t have control over the API logic or parameter names. |
Thanks for the update @tim-finnigan Upon reading the issue you mentioned, basically, what is happening is, I assume is when “max-items” is specified, the “no-paginate” option is getting silently added. And the other issue is AWS broken api not returning next token. If they fix their api, the cli command should ideally just work (again I assume). Do you know of the best way to raise the issue directly with aws to fix their sqs api? |
I'll reach out to the SQS team regarding this but can't guarantee if or when they would update their API behavior. You can also try opening a support case with AWS to help escalate this if it is a blocker for you. |
P63886091 |
Thanks so much @tim-finnigan! |
We haven't received any update yet but I'm going to transfer this to our cross-SDK repository as the issue relates to the SQS ListQueues API rather than the CLI directly. |
Same issue here. We have a LOT of queues and it seems there's no way for me to programmatically do things with them. It would be so, so nice if we could filter |
I can't find any way to use the next token or CLI to get a queue count past 1,000. |
Checking in to highlight the API documentation again: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ListQueues.html
Pagination behavior may vary slightly between the CLI and SDKs, but the underlying API is the limiting factor here. And the current behavior is unlikely to change due to the need to maintain backwards compatibility with previous versions. We can help provide guidance for individual issues as I think there are some nuances to the different things that have been reported here. We recommend reaching out through AWS Support for further assistance if you have a support plan, or create an issue in the individual repository for the CLI/SDK you are using if you have encountering general pagination issues. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Hi @tim-finnigan The docs state
So, if there are say 1500 queues to return, I expect the first API call to return 1000 + a NextToken, then I expect AWS CLI to automatically use the next token to fetch the next page of 500. I am totally confused why you believe this is an SQS problem, when it seems like a problem with the CLI and it's implementation for this service. I am also confused _where _ I should reraise this issue. It was originally raised under aws/aws-cli, then moved to aws/aws-sdk. There is no specific repos for the AWS services that I can see, and the aws-cli is what I am having the problem with. Could you assist? |
Hi @captainfalcon23 thanks for following up and apologies for any confusion on my end. I think this comment summarizes the issue well: https://repost.aws/questions/QUi7KyD3R_RlWYTqlBGvZaGQ/how-to-get-a-list-of-all-sqs-queues#ANeUpycZ2DRJKHPcGOBeQWyw This behavior does seem to contradict the CLI pagination documentation: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html#cli-usage-pagination-serverside
I'm going to transfer this issue back to the CLI repository for further investigation. Thanks for your patience here. In the meantime you can use the approach mentioned on the post linked above or use an SDK like Boto3 to get all of the results: import boto3
client = boto3.client('sqs', region_name='us-west-2')
paginator = client.get_paginator('list_queues')
operation_parameters = {'MaxResults': 1000}
page_iterator = paginator.paginate(**operation_parameters)
for page in page_iterator:
print(len(page['QueueUrls'])) |
Hi @captainfalcon23 - I wanted to check in again regarding this earlier comment, it looks like the issue there is that I should also note that only using To clarify: As I described in boto/boto3#3406 (comment), specifying |
Hi @tim-finnigan
EXPECTATION: So yeah it looks like specifying page-size makes it work, so the problem definitely lies within the aws-cli and unable to automatically do pagination without further input. Regarding the point of --next-token vs --starting-token, that looks like another bug. It seems --next-token is not documented in the CLI help, nor the AWS docs, but exists as a CLI argument |
Checking in again — the
And then using that token like this to get additional queues:
But if you just specify
(And if you add So this use case can be met with the above approach. Maybe the AWS CLI docs on pagination could better clarify this behavior, in which case I recommend using the Provide feedback link on that page to send feedback directly. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
As per AWS documentation - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sqs/list-queues.html
It seems in an account where there are > 1000 queues, there are two issues:
Expected Behavior
AWS CLI will return ALL SQS queues, and dymamically perform paging, as it does with other services.
In addition, NextToken should be provided in the response if I do NOT specify "--max-items"
Current Behavior
See "describe the bug" section.
Reproduction Steps
Try running the below in an account with > 1000 queues:
Possible Solution
Implement CLI auto paging as per almost every other aws service
Additional Information/Context
No response
CLI version used
aws-cli/2.4.19 Python/3.8.8 Linux/5.10.102.1-microsoft-standard-WSL2 exe/x86_64.centos.7 prompt/off
Environment details (OS name and version, etc.)
Centos 7.9 WSL
The text was updated successfully, but these errors were encountered: