Skip to content
This repository has been archived by the owner on Jan 20, 2019. It is now read-only.

Support filtering in describe instances #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/AWS/EC2/instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,20 @@ def run_instances( options = {} )
# instance is specified that does not exist a fault is returned. If an instance is specified that exists but is not
# owned by the user making the request, then that instance will not be included in the returned results.
#
# An optional filter can be provided to to request information for instances that corresponds this filter only
#
# 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
#
# @option options [Array] :instance_id ([])
# @option options [Hash] :filter ({})
#
def describe_instances( options = {} )
options = { :instance_id => [] }.merge(options)
params = pathlist("InstanceId", options[:instance_id])
options = { :instance_id => [], :filter => {} }.merge(options)
params = {}
params.merge!(pathlist("InstanceId", options[:instance_id]))
params.merge!(pathhashlist("Filter", options[:filter].map{|k,v| {:name => k.is_a?(Symbol) ? k.to_s.gsub("_", "-") : k, :value => v}}, {:name => 'Name', :value => 'Value'}))

return response_generator(:action => "DescribeInstances", :params => params)
end

Expand Down Expand Up @@ -296,4 +302,3 @@ def self.local_instance_meta_data

end
end