Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add filtering for describe_instances #57

Closed
wants to merge 1 commit into from

2 participants

@joshstaiger

EC2 supports filtering for the describe_instances command. This adds support for it.

@bcarpenter

Looks like a nice addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 12, 2011
  1. @joshstaiger
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/AWS/EC2/instances.rb
View
11 lib/AWS/EC2/instances.rb
@@ -85,11 +85,22 @@ def run_instances( options = {} )
# Recently terminated instances will be included in the returned results for a small interval subsequent to
# their termination. This interval is typically of the order of one hour
#
+ # The results can be filtered using the filter argument. The EC2 API reference for a full description of
+ # filter types and arguments.
+ #
+ #
+ # @example
+ # @ec2.describe_instances(:instance_id => 'i-a37582c3', :filter => [{"tag:Role" => "App"}])
+ #
# @option options [Array] :instance_id ([])
+ # @option options [Array] :filter ([])
#
def describe_instances( options = {} )
options = { :instance_id => [] }.merge(options)
params = pathlist("InstanceId", options[:instance_id])
+ if options[:filter]
+ params.merge!(pathkvlist('Filter', options[:filter], 'Name', 'Value', {}))
+ end
return response_generator(:action => "DescribeInstances", :params => params)
end
Something went wrong with that request. Please try again.