Skip to content

Instantly share code, notes, and snippets.

@trevorrowe
Created November 20, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorrowe/2b85c2b1692cfe1d14a6 to your computer and use it in GitHub Desktop.
Save trevorrowe/2b85c2b1692cfe1d14a6 to your computer and use it in GitHub Desktop.
Listing EC2 instances
# using EC2 client
ec2 = Aws::EC2::Client.new
ec2.describe_instances.each_page do |resp|
resp.reservations.each do |reservation|
reservation.instances.each do |intsance|
puts instance.instance_id
end
end
end
# using EC2 resource interface
ec2 = Aws::EC2::Resource.new
ec2.instances.each do |instance|
puts instance.id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment