Pagination and error handling
The AWS Command Line Interface (CLI) reports errors that help identify why a command failed. For an access denied error, check the caller’s identity and permissions.
How it works
- Check the command’s return codeA return code is the process status that a CLI command reports after it finishes., the process status reported to the script, and inspect the error details.
- For access denied, check the caller’s identity and permissions. For invalid parameters, correct the syntax or values.
- Use
--debugto inspect processing details, including parameter parsing, requests and responses.
Exam cues
- If a deployment command returns access denied, think check the caller’s identity and permissions, because the error points to an access problem.
- If a command has invalid parameters, think correct the syntax or values, because the request needs correction.
Remember
- Return code
252indicates invalid syntax or parameters;253indicates an invalid environment or configuration;254means the service returned an error. - For S3 transfers, code
1indicates a failed transfer, while code2can indicate skipped files.
Trap: Return code
2can also mean a command parsing failure; its meaning depends on the command.
Fetch page
Follow continuation
Da documentação da AWS (10)
- The --no-paginate option stops automatic token following and returns only the first service page.
- If a service changes item order, different --page-size and --max-items values can cause missing or duplicate results; align them or retrieve the complete list.
- AWS CLI v2 uses standard retry mode by default, with two retries after the initial call for three total attempts.
- AWS_RETRY_MODE and AWS_MAX_ATTEMPTS configure retry behavior; max_attempts includes the initial call.
- Access denied errors require checking identity and permissions; invalid command parameters require correcting syntax or values.
- CLI return code 252 indicates invalid command syntax, an unknown parameter or an incorrect parameter value that prevents execution.
- CLI return code 253 indicates invalid environment or configuration, including missing credentials.
- CLI return code 254 indicates the request reached the service and the service returned an error.
- For S3 transfer commands, code 1 indicates a failed transfer and code 2 can indicate skipped files; code 2 also represents command parsing failures.
- The --debug option shows processing details including parameter parsing, requests, raw responses and formatted output.
CLI pagination and retries
The AWS CLI can retrieve paginated lists and retry supported temporary errors. These behaviors help scripts process inventory results and handle transient failures. PaginationPagination divides a large service result set into smaller pages retrieved through separate calls. | Retry modes
How it works
- For supported paginated list commands, the CLI retrieves all pages by default, using the service’s default page size. Set
--page-sizeto change the items requested per service call. Smaller pages can reduce timeouts without limiting the total retrieved. - Use
--max-itemsto limit the output batch. If more items remain, retain theNextTokenand pass it as--starting-tokento resume. Do not pass a null or empty token. - Standard retry mode retries supported connection, timeout and throttlingThrottling is a service response that limits an excessive request rate and can be retried. errors, as well as HTTP 500, 502, 503 and 504 responses. It uses exponential backoffExponential backoff increases waiting time between retry attempts. between attempts.
- Check the return codeA return code is the process status that a CLI command reports after it finishes.:
0indicates success without CLI or service errors.
Exam cues
- If an inventory times out, think smaller
--page-size, because it reduces items per service call while the CLI can still retrieve all pages. - If a script must process a limited batch and resume later, think
--max-itemsand--starting-token, because the returnedNextTokenidentifies where to continue. - If a command encounters throttling or a transient connection error, think standard retries with exponential backoff, because those errors are supported by the retry mode.
Remember
- Standard retry backoff uses a base factor of two and a maximum delay of 20 seconds.
- AWS CLI v2 uses a client-side display pagerA pager is a local program that displays terminal output one screen at a time. by default.
- Return code
0means the command succeeded without CLI or service errors.
Trap:
--no-cli-pagerdisables the display pager, but does not disable API pagination.
Da documentação da AWS (8)
- For supported paginated list commands, the AWS CLI retrieves all pages by default using the service-specific default page size.
- The --page-size option changes the items requested per service call without limiting the total results retrieved; smaller pages can reduce timeouts.
- The --max-items option limits items in CLI output and returns a NextToken if more items remain.
- Pass the CLI NextToken as --starting-token to resume; do not pass a null or empty starting token.
- AWS CLI v2 uses a client-side display pager by default; --no-cli-pager disables that display pager without disabling API pagination.
- Standard mode retries supported transient connection and timeout errors, throttling errors, and HTTP 500, 502, 503 and 504 responses.
- Standard retry mode uses exponential backoff with a base factor of two and a maximum backoff of 20 seconds.
- CLI return code 0 indicates command success with no CLI or service errors.
Flashcards
Nada para revisar aqui agora. Escolha outros tópicos ou outro filtro.
·
Todos os 8 flashcards em lista
An AWS CLI command returns an access denied error during an infrastructure deployment. What should the team check?
Check the caller identity and permissions.
A script uses the AWS CLI to inventory resources across a paginated list operation. Does it need to request each page manually?
No. For supported paginated list commands, the AWS CLI retrieves all pages by default.
An AWS CLI inventory times out while retrieving a large list. How can the team reduce the size of each service request?
Reduce the service page size. The CLI can still retrieve the complete list across multiple requests.
An AWS CLI automation needs to process a limited batch of list results and continue later. What should it retain?
Retain the returned continuation token and use it to resume the listing.
A team disables the AWS CLI display pager in an inventory script. Does this stop automatic retrieval of service pages?
No. The display pager and API pagination are separate. Disabling the display pager does not disable pagination.
An AWS CLI automation encounters a temporary service throttling error. What built-in behavior can help?
Standard retry mode retries supported throttling and transient errors with exponential backoff.
An AWS CLI automation checks whether a command completed without CLI or service errors. Which return code indicates success?
Return code 0 indicates success without CLI or service errors.
An AWS CLI automation receives a transient connection error. How does standard retry mode space its retry attempts?
It uses exponential backoff between retries.