pfhayes
pfhayes

Reputation: 3927

EC2 Instance Search in API

In the AWS EC2 console on the web, there is a search box that allows you to search for instances by keyword. It appears that this searches many fields (such as hostname, tags, instance state, etc.) for the provided keyword.

Here is an example of searching for the keyword "running". The UI shows a filter named "search" with the search value "running". It appears that this returns instances in the "running" state but also instances named "running", with a tag value of "running", a hostname of "running", etc.

Example search for running

Is this functionality available through the API? The describe-instances API call has filters, but it appears as though there is no documented filter that matches this behaviour (which searches all fields instead of just the specified ones). I've tried a filter named "search" but that does not work.

Upvotes: 1

Views: 298

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 269470

There is no API equivalent that search all fields (eg state, name, tag). However, you could emulate this by retrieving details of ALL instances via the API and then having your app filter the results.

Upvotes: 1

Tommy
Tommy

Reputation: 8178

One way I think it can be done is using aws ec2 describe-instances (use corresponding API in your preferred language sdk) and do a regex to filter out the results.

Upvotes: 0

Related Questions