How to Customize the AWS CLI Output Format?
This guide will explain the process of customizing the AWS CLI formats.
How to Customize the AWS CLI Output Format?
AWS CLI offers multiple formats for getting the output after executing its commands on the Windows terminal. Users can easily set the default output format while configuring the AWS CLI using its IAM user credentials. To learn how to configure AWS CLI, follow this guide and then simply change the output format using the “configure” command in the command prompt:
AWS CLI Output Formats
AWS CLI offers different methods of displaying outputs for managing its services and resources using commands. The user can simply set the default output format to get all outputs in a particular format and the platform also enables the user to change the format by setting it with the query. All the formats offered by the platform to display AWS CLI outputs are as follows:
- JSON Output Format
- YAML Output Format
- YAML Stream Output Format
- Text Output Format
- Table Output Format
JSON Output Format
JSON is used to display data in textual form, and it is the most used AWS CLI output format as most programming languages can easily decode the JSON text. The user can get the output in JSON format containing the list of all the IAM users in the AWS account by executing the following code:
The list of IAM users has been displayed in the JSON format:
YAML Output Format
YAML is another format that can be used to get the AWS CLI outputs. It is a good choice as most of the services like CloudFormation use its formatting. Now, get the list of IAM users in the YAML format by running the command mentioned below:
The details of the IAM user have been displayed in the YAML format as displayed in the screenshot below:
YAML Stream Output Format
To take the YAML format to the next level, use the YAML Stream to get the huge data efficiently and provide a more interactive/faster response:
The IAM user’s list is displayed with its details like ARN, CreateDate, etc. in YAML Stream format displayed in the following snippet:
Text Output Format
The text output format simply displays the output in a single line and organizes the data in tab-delimited lines:
Table Output Format
The name simply suggests that this format displays the output in tabular form with column names suggesting the data stored in its cells:
The following screenshot displays the output in table format for the IAM users in the AWS account:
That is all about customizing the output formats of the AWS CLI commands.
Conclusion
To customize the output format of the AWS CLI response, simply configure AWS CLI to set the default output format. The user can also set the output format with each query using the “–output” with the name of the format offered by the platform to get the response in the said format. This post illustrated the process of customizing AWS CLI output formats.
Source: linuxhint.com