3

I am following the documentation to use the --query option in aws cli. However it doesn't work for me at all. I have defined profiles because I have several accounts to pull the data. If I omit the --query, it returns the data successfully. Any insight into this please?

Thank you

> aws --version
aws-cli/1.14.8 Python/3.6.3 Windows/10 botocore/1.8.12

> aws ec2 describe-volumes --profile TEST1 --region us-east-1 --query 'Volumes[0]'
"Volumes[0]"

> aws ec2 describe-volumes --profile TEST1 --region us-east-1
{
    "Volumes": [
        {
            "Attachments": [ ....
Rafaf Tahsin
  • 7,652
  • 4
  • 28
  • 45
Ben
  • 69
  • 5

2 Answers2

9

Change from single quotes to double quotes:

aws ec2 describe-volumes --profile TEST1 --region us-east-1 --query "Volumes[0]"
John Hanley
  • 74,467
  • 6
  • 95
  • 159
0

As soon as i switched to powershell, it works successfully. Although I am not sure why it requires using powershell.

Ben
  • 69
  • 5
  • 1
    PowerShell accepts both single and double quotes. The vanilla command line does not. See https://superuser.com/questions/324278/how-to-make-windows-command-prompt-treat-single-quote-as-though-it-is-a-double-q. – jarmod Dec 15 '17 at 02:08