AWS CLI Filter Output With Query & Filter Options
Channel: Web Technology Funda
Date: 2018-05-13

AWS CLI Filter Output With Query & Filter Options

http://www.howtoinmagento.com/2018/03/aws-cli-filter-output-with-query-filter.html

This will be helpful to get specific output from AWS request command. There are two type of filters provided by AWS.
Filter Output on Client Side or Query Option
Filter Output On Server Side or Filter Option

The server side filter is much faster than and efficient filter than client side (Query) but query option provides robust feature for most of commands supported by AWS CLI as compare to filter option.

Note: AWS CLI is case sensitive framework.

Filter Output On Server Side or Filter Option:

For example, If we want to see detail of any specific instance detail like t2.micro instance using filter option we can use command below to filter it out.

$ aws ec2 describe-instances --filter Name=instance-type,Values=t2.micro

In this command Name=instance-type is the output field name on which we want to filter and Value=t2.micro is value of that field

Filter Output on Client Side or Query Option:

As there are some limitations in AWS filter option that, it is generally supported by 'list' and 'describe' command and not for all AWS commands. In this case the 'Query' option can help us to filter out large amount of data. AWS Query command is different than Filter option command, it runs on client side.

Lets see command below:

$ aws ec2 describe-regions --query 'Regions[?RegionName==`us-west-2`]'

Please note here query expression is enclosed in single quotes but value for inside expression using 'backquote' character(`). The query written in this expression is in specific format following JEMSPath specification.

If we run only below command

$ aws ec2 describe-regions 

It will show all the available regions supported by AWS, as of now AWS global infrastructure is spread across 16 AWS regions and in future it will increase across the world.

You can see in query example  command 'Regions [' is the parent field and [?RegionName is child field of region and value is 'us-west-2' which will be use for filter the output.

OutPut$

[
 { "Endpoint":"ec2 us-west-2.amazonaws.com",
   "RegionName":"us-west-2"
 }
]

The conclusion is Filter option is filter output on server side and hence it is more efficient however filter options has some limitations where as Query option supports universally by all CLI commands.

PHP Web Technology Funda | AWS Cloud 

Read my blog here : https://www.howtoinmagento.com/

Tips & Tricks of PHP Frameworks & AWS Cloud Computing

aws,awscli,cloud,awscloud,awscomputing,computing,s3,lambda,cli,ec2,ses,aws,cloud,amazon web services,aws console,amazon aws,cloud computing,amazon s3,amazon cloud,aws login,amazon ec2,ec2,amazon services,amazon website,ec2 pricing,aws s3,aws pricing,cloud services,aws ec2,aws ec2 pricing,what is aws,aws cost calculator,azure vs aws,amazon web service,aws services,amazon cloud services,amazon storage,aws cloud,amazon cloud storage,aws sign in,amazon aws login,cloud technology,cloud server,aws s3 pricing,cloud hosting,cloud service providers,aws instance pricing,ec2 instance pricing,aws security,amazon web services login,amazon aws console,aws down,amazon server,what is amazon web services,cloud computing services,ams amazon,aws architecture,aws support,amazon web hosting,aws conference,aws server,aws wordpress,azure cloud service,amazon web services certification,cloud computing companies,amazon aws pricing,cloud providers,aws developer,amazon hosting,amazon service number,aws hosting,aws cost,ec2 console,cloud computing security,aws data centers,amazon aws certification,amazon web servies,amazon service,aws website hosting,cloud solutions,what is amazon aws,aws storage,aws partner,amazon web services pricing,aws wiki,aws web hosting,amazon ews,amazon web,aws sign up,aws meaning,amazon cloud computing,amazon aws free,aws portal,aws managed services,aws storage pricing,aws services list,aws products,aws service status,aws locations,aws s3 cost,ec2 cost,amazon web services logo,cloud hosting providers,aws web services,aws cost estimator,aws consulting,aws charges,aws,amazon aws,aws console,aws lambda,cli,aws cli,aws s3,aws ec2,aws ec2 pricing,aws rds,aws cli install,aws configure,aws vpc,install aws cli,aws iam,aws iot,aws cli s3,aws console login,aws s3 cli,aws s3 cp,aws s3 sync,amazon aws console,aws command line tools,aws command line,aws command not found,aws iam role,aws cli configure,aws cli credentials,aws cli windows,aws s3 ls,aws cli download,aws cli ec2,aws cli lambda,aws cli profile,aws cli assume role,aws cli commands,aws cli mac,aws cli query,update aws cli,amazon cli,aws cli dynamodb,aws cli version,aws iam login,brew install aws cli,pip install awscli,aws cli cloudformation,aws cli environment variables,aws cli login,aws cli region,aws client