AWS CLI

 AWS CLI Pagination

  • You can control the number of items included in the output when you run a CLI command.
  • By default, the AWS CLI uses a page size of 1000.
  • i.e. If you run “AWS S3 api list–objects my-bucket” on a bucket which contains 2500 objects, the CLI actually makes 3 API calls to S3 but displays the entire output in one go.
AWS CLI Pagination- Errors
  • If you see errors when running list commands on a large number of resources, the default page size of 1000 might be too high.
  • You are most likely to see a “timed out” error, because the API call has exceeded the maximum allowed time to fetch the required results.
Fixing AWS CLI Pagination- Errors
  • To fix this, use the  - -page-size option to have the CLI request a smaller number of items from each call.
  • The CLI still retrieves the full list, but performs a large number of API calls in the background, and retrieves a smaller number of items with each call.
  • The commands are as follows
    • aws s3 api list-objects - - bucket my-bucket - - pagesize 100.
    • - - max-items option to return fewer items in the CLI output.
    • aws s3 api list-objects - - bucket my-bucket - - max-items 100

Comments

Popular posts from this blog

Effect : Deny vs No Action

AWS Summaries

Infrastructure Setup using Cloud Formation Templates