简体   繁体   中英

How to change the default output format in AWS CLI?

During the aws configuration in CLI I use the command "aws configure", then i type the access key, secret access key, default region and default output type as "table".

What command i need to use in aws CLI to get the output in json format . For example if i use the command "aws ec2 describe-volumes --output json". Then it will give the output in JSON format only for this command. How to change Default output from table to json?

According to the documentation there are two ways to set the default output format

  1. Using the output option in a named profile in the config file. The following example sets the default output format to json .
[default]
output=json
  1. Using the AWS_DEFAULT_OUTPUT environment variable. The following output sets the format to json for the commands in this command-line session until the variable is changed or the session ends. Using this environment variable overrides any value set in the config file.
$ export AWS_DEFAULT_OUTPUT="json"

The first option will be the persistent one.

The output format for AWS CLI is initially set while configuring the CLI using the command

aws configure

This command can be used again to change the output format permanently. Just press enter for the first three prompts (Access Key ID, Access Key and region name) and enter the desired output format in the last prompt and you're set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM