AWS CLI EC2 describe-instances command; how does the `ip-address` filter work?

I am learning how to use the CLI tool for AWS and I come across this command:

aws ec2 describe-instances --filters "Name=ip-address,Values=my.test.ip.address"

The command works fine and I can see the EC2 instance details in the command output, however, it does not have any field with the name ip-address. Instead, it has PublicIp and PublicIpAddress fields that contain the ip address which I am looking for.

How does this filter work?

>Solution :

There is a list of keys which can be used to filter on. This can be found in the documentation for the describe-instances command: --filter. One of them ip-address:

ip-address – The public IPv4 address of the instance.

I did not take a look on the source code for the describe-instances, but I believe it parses the JSON response and it has a preconfigured path for each of the filters.

Update:

After takin a look at the source code if aws-cli on GitHub, all the commands are transformed into API calls and send to AWS. All the filtering is happening in the back-end.

Leave a Reply