Skip to content
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

awscli IAM list-users and list-access-keys doesn't parse max-items to request body #8800

Open
shirady opened this issue Jul 15, 2024 · 2 comments
Assignees
Labels
pager issues related to AWS_PAGER, cli_pager, or other client-side paging (not API pagination)

Comments

@shirady
Copy link

shirady commented Jul 15, 2024

Describe the bug

Hello,
I'm using a local endpoint and I noticed that when I use the actions IAM list-users and list-access-keys the argument max-items is passing to the CLI but it doesn't parse it in the request body.

Expected Behavior

I would expect to see the max-items in the request body params.

Current Behavior

I don't see the max-items in the request body (as mentioned I can see it passed as argument).

Reproduction Steps

  1. iam list-users
    s3-nc-user-1-iam iam list-users --path-prefix /abc/ --max-items 7 --debug
    I added the --path-prefix flag to see a flag that passes (and a flag --max-items I think doesn't pass).
    (s3-nc-user-1-iam is an alias
    for AWS_ACCESS_KEY_ID=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:7005).

In the debug I see AWS CLI list the argument of max-items:

2024-07-07 08:43:35,751 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--no-verify-ssl', '--endpoint-url', 'https://localhost:7005', 'iam', 'list-users', '--path-prefix', '/abc/', '--max-items', '7', '--debug']

In the debug I don't see the max params passing to the request's body (PathPrefix we can see):

2024-07-07 08:43:35,836 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=ListUsers) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': 'aws-cli/2.15.36 Python/3.11.9 Darwin/23.4.0 source/arm64 prompt/off command/iam.list-users'}, 'body': {'Action': 'ListUsers', 'Version': '2010-05-08', 'PathPrefix': '/abc/'}, 'url': 'https://localhost:7005/', 'context': {'client_region': 'us-east-1', 'client_config': <botocore.config.Config object at 0x1083b49d0>, 'has_streaming_input': False, 'auth_type': None}}
  1. iam list-access-keys:
    s3-nc-user-1-iam iam list-access-keys --max-items 1 --user-name shira-1001 --debug

In the debug I see AWS CLI list the argument of max-items:

2024-07-07 09:03:15,120 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--no-verify-ssl', '--endpoint-url', 'https://localhost:7005', 'iam', 'list-access-keys', '--max-items', '1', '--user-name', 'shira-1001', '--debug']

In the debug I don't see the max params passing to the request's body (UserName we can see):

2024-07-07 09:03:15,228 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=ListAccessKeys) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': 'aws-cli/2.15.36 Python/3.11.9 Darwin/23.4.0 source/arm64 prompt/off command/iam.list-access-keys'}, 'body': {'Action': 'ListAccessKeys', 'Version': '2010-05-08', 'UserName': 'shira-1001'}, 'url': 'https://localhost:7005/', 'context': {'client_region': 'us-east-1', 'client_config': <botocore.config.Config object at 0x106fa89d0>, 'has_streaming_input': False, 'auth_type': None}}

Possible Solution

You can parse the max-items and add it to the request body.

Additional Information/Context

CLI version: aws-cli/2.17.11 Python/3.11.9 Darwin/23.4.0 source/arm64

CLI version used

2.17.11

Environment details (OS name and version, etc.)

MacOS 14.4.1

@shirady shirady added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 15, 2024
@tim-finnigan tim-finnigan self-assigned this Jul 15, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 15, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. Linking CLI pagination documentation for reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html

The behavior you described is expected. The AWS CLI uses a paginate customization to provide consistent pagination across services. For example commands like sqs list-queues expects MaxResults in the API request, but --max-items will still be mapped to that via the CLI. You should see a line like this in your debug logs:

awscli.customizations.paginate - DEBUG - Modifying paging parameters for operation: ListUsers

@tim-finnigan tim-finnigan added closing-soon This issue will automatically close in 4 days unless further comments are made. pager issues related to AWS_PAGER, cli_pager, or other client-side paging (not API pagination) and removed bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels Jul 15, 2024
@shirady
Copy link
Author

shirady commented Jul 16, 2024

@tim-finnigan thank you for the comment.
I could see awscli.customizations.paginate - DEBUG - Modifying paging parameters for operation: ListUsers in the output.
As I understand it, to see the value of this parameter I need to add the flag --no-paginate, correct?

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pager issues related to AWS_PAGER, cli_pager, or other client-side paging (not API pagination)
Projects
None yet
Development

No branches or pull requests

2 participants