Search code examples
amazon-web-servicespaginationaws-cli

How to paginate over an AWS CLI response?


I'm trying to paginate over EC2 Reserved Instance offerings, but can't seem to paginate via the CLI (see below).

% aws ec2 describe-reserved-instances-offerings --max-results 20                                                                                 
{
    "NextToken": "someToken", 
    "ReservedInstancesOfferings": [
        {
             ...
        }
    ]
}
% aws ec2 describe-reserved-instances-offerings --max-results 20 --starting-token someToken
Parameter validation failed:
Unknown parameter in input: "PaginationConfig", must be one of: DryRun, ReservedInstancesOfferingIds, InstanceType, AvailabilityZone, ProductDescription, Filters, InstanceTenancy, OfferingType, NextToken, MaxResults, IncludeMarketplace, MinDuration, MaxDuration, MaxInstanceCount

The documentation found in [1] says to use start-token. How am I supposed to do this?

[1] http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-reserved-instances-offerings.html


Solution

  • Looks like some busted documentation.

    If you run the following, this works:

    aws ec2 describe-reserved-instances-offerings --max-results 20 --next-token someToken
    

    Translating the error message, it said it expected NextToken which can be represented as next-token on the CLI.