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 ?
JSON is the default output format of the AWS CLI. Most programming languages can easily decode JSON strings using built-in functions or with publicly available libraries.
The Default output format specifies how the results are formatted. The value can be any of the values in the following list. If you don't specify an output format, json is used as the default. json – The output is formatted as a JSON string. yaml – The output is formatted as a YAML string.
To switch between different AWS accounts, set the AWS_profile environment variable at the command line via export AWS_PROFILE=profile_name . Setting the env variable changes the default profile until the end of your shell session or until you set the variable to a different value.
Where are configuration settings stored? The AWS CLI stores sensitive credential information that you specify with aws configure in a local file named credentials , in a folder named . aws in your home directory.
According to the documentation there are two ways to set the default output format
output
option in a named profile in the config
file. The following example sets the default output format to json
.[default]
output=json
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With