I am currently learning the AWS CLI (v2) and have installed it on Ubuntu 18.04. I am running zsh with oh-my-zsh installed. I am trying to get aws command output to be reported back to the terminal as a JSON string (or even as text), but the output is always redirected to vi.
My AWS account is brand new - no EC2 instances. When I run the following command:
aws ec2 describe-instances
It sends the expected output value (e.g. { "Reservations": [] }), but directly to vi instead of outputting a JSON string to the terminal requiring closing vi afterwards. This occurs regardless of output format (json, text, table) or what shell I use (bash, zsh).
I am not sure if this is a AWS CLI configuration issue/change or a shell/Linux configuration issue/change
Thank you for any/all suggestions.
1 Answer. Use the output option in the named profile in the 'config' file. It sets the default output format to JSON. Do check out AWS Training by Intellipaat and master AWS.
If the aws command cannot be found after first installing or updating the AWS CLI, you might need to restart your terminal for it to recognize any PATH updates. If the aws command cannot be found after first installing or updating the AWS CLI, it might not have been fully installed.
By default, the AWS CLI sends requests to AWS services by using HTTPS on TCP port 443. To use the AWS CLI successfully, you must be able to make outbound connections on TCP port 443. To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.
The default value is auto . A Boolean switch that enables debug logging. The AWS CLI by default provides cleaned up information regarding any successes or failures regarding command outcomes in the command output. The --debug option provides the full Python logs.
It was the PAGER environment variable set to "less" (which I was confusing with vi).
This fix is to update the ~/.aws/config file and setting cli_pager to an empty value, e.g. :
[default] region = us-west-2 output = json cli_pager =
Thank you to Sorin who commented on my question lead me to the answer.
Just run your command with --no-cli-pager
like so
aws ec2 describe-instances --no-cli-pager
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