Quick Outline
In this article, we will learn about:
- What is Pager in AWS CLI?
- What is Pagination in AWS CLI?
- What is the Difference Between the Pager and Pagination?
- Why Disabling the Pager in AWS CLI?
- How to Disable Pager in AWS CLI?
- Conclusion
Oftentimes, you have encountered that while executing a command in AWS CLI, it does not list all the data once and prompts the user to press the “Enter” key. Have you ever thoughts that why and how this happens in AWS CLI?
Before understanding how this happens, let’s explore what causes this to happen. The Pager and Pagination are the two core concepts of this functionality. Let’s explore these concepts in this article.
What is Pager in AWS CLI?
Pager in AWS CLI is a tool or utility that displays the long lists of the data in a readable manner. By default, in AWS CLI, the pager is enabled and supports multiple AWS services. A Pager comes into play when there is more data to display in the output than the available space on the terminal window. In AWS CLI, the pager will make multiple API calls to the AWS service to list more data.
What is Pagination in AWS CLI?
Pagination is a concept that breaks down larger sets of data into smaller chunks for listing it in the response. There are various AWS services that support the pagination if they are accessed via CLI. Pagination improves the readability and performance of the AWS CLI and prevents the timeout error. In pagination, the results are not fetched once. Instead, the AWS CLI retrieves a subset of huge data that is to be displayed in the output and make multiple API calls to the service for listing more records.
What is the Difference Between the Pager and Pagination?
Pager and Pagination are related terms and often result in confusion. Given below are a few key differences of the two concepts:
Pager | Pagination |
Pager is a tool that supports pagination. | Pagination is a technique for listing the larger chunks of data in the form of smaller subsets. |
Pager is most commonly used in the Command Line interfaces. | However, pagination is supported by both the GUI and CLI. |
Why Disabling the Pager in AWS CLI?
Disabling the pager is useful in cases where there is small data to list and there is no need to make excessive API calls to the service. Hence, the AWS CLI will attempt to access the data at once and does not contain any additional token in the output as there will be no more data to list. Different parameters are available to disable the pager in AWS CLI.
Prerequisites
Below are the prerequisites for this tutorial:
- AWS CLI installed.
- AWS credentials configured on the CLI.
How to Disable Pager in AWS CLI?
Consider a S3 bucket that contains multiple objects e.g., 500 objects. When a user lists the objects via CLI in the S3 bucket, the AWS CLI will make multiple API calls to S3 buckets and fetch a small chunk of data each time. To list the data at once, the user can disable the pager by following methods:
- Method 1: Disable Pager by “–no-cli-pager” in AWS CLI
- Method 2: Disable Pager by “cli_pager” in AWS CLI
Before implementing the methods, first log into your AWS CLI. Open the CMD by searching it in the Windows search bar:
Use the following command for signing into the AWS account via CLI:
Provide the credentials i.e., Access Key and Secret Access key if configuring the CLI first time. Otherwise, press “Enter” to proceed further:
Method 1: Disable Pager by “–no-cli-pager” in AWS CLI
Before disabling the pager, the CLI prompts the user to press the “Enter” key to list more records:
To disable the pager and retrieve the data all at once from the S3 bucket, use the following command in the Command prompt:
In the output of the command, we can see that all the records are fetched and displayed at once, and it does not return any tokens for listing additional data. The output of the command is as follows:
Method 2: Disable Pager by “cli_pager” in AWS CLI
Another method of disabling the pager is by modifying the config file of the AWS. The following command opens the configuration file in notepad:
Note: The user can also open this file by following this path “C:\Users\%Username%\.aws”. Click on the “config” file in this directory.
Bonus Tip: Resolve “Path not specified” in Notepad.
The config file will contain the [default] setting of the AWS CLI. However, if the notepad displays the “The system cannot find the path specified”, enter the below-mentioned command:
This will open the notepad. Paste the following script in the [default] section and keep the rest of the settings unchanged:
Press “CTRL + S” from the keyboard to save and apply the changes:
To verify if the configurations have been successful or not, execute the following command in the CLI:
This should not prompt the user to hit the “Enter” key for listing more data. The output given below verifies the configuration:
Similarly, the pager in the CLI can also be disabled by configuring the “AWS_PAGER” environment variable. For this purpose, commands are mentioned below.
For Windows
Setting the AWS_PAGER to an empty string will disable the pager in the CLI. Execute the following command in the AWS CLI:
For Linux/MacOS
The command given below can be used for both operating systems i.e., Linux and MacOS:
Bonus Tip: Enable Pager
Under the “default” section of the config file, remove the “cli_pager=” for enabling the pager in AWS CLI. After removing the text, press “CTRL + S” from the keyboard to save and apply changes:
Re-run the following command to verify if the pager is enabled:
The output of the command verifies that the pager has been enabled successfully:
That is all from this guide.
Conclusion
To disable the pager in AWS CLI, the parameters used are “–no-paginate”, and “–no-cli-pager” and an environment variable “AWS_PAGER”. A pager is a helpful tool when it comes to listing the huge volumes of data in the output. In the command line, a user can use these parameters with multiple services which will temporarily disable the pagination for that service. However, configuring the environment variable can result in the permanent disabling of this tool. This article provides a step-by-step demonstration of disabling the pager in AWS CLI