Querying

The CLI tool supports transforming the response from the API with the --query option. This option takes a JMESPath query as a parameter and returns the query result.

JMESPath is a query language for JSON. For more information, visit http://jmespath.org/.

As the query is processed as part of the command, it takes place on the server, not the client. By offloading work to the server, you can reduce the size of the resulting payload and improve response times.

JMESPath can be used to transform the response that you receive:

$ aws ec2 describe-availability-zones 
--output json
--query "AvailabilityZones[].ZoneName"
[
"us-east-1a",
"us-east-1c",
"us-east-1d",
"us-east-1e"
]

It can also be used to filter the data that is received:

$ aws ec2 describe-availability-zones 
--output json
--query "AvailabilityZones[?ZoneName == 'us-east-1a'].State"
[
"available"
]

Using the --query option can open up a number of possibilities to give you flexible options for solving problems with the AWS CLI.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset