Monday, November 14, 2016

Describing AWS Instances

Amazon uses the idea of "describing" resources using filters quite a bit.

A filter in python terms is a list of maps, and each value in the map's key-value pairs can be a list. The documentation is a little light on details, intentionally I believe, because the format is extremely flexible. A few examples of using this in Python and Powershell are below



If you wanted to get all of the instances that have a Name tag with the value webserver, you would use

filters = [{'Name':'tag:Name', 'Values': ['*Webserver*']}]

Here is an example of using this concept in a python script:


And here is the same thing in powershell.
And just for extra fun, once you have the instance objects in Powershell it's pretty easy to pipe them to other commandlets, like "where" to filter by instance type:

No comments:

Post a Comment