Created
November 20, 2015 23:09
-
-
Save trevorrowe/2b85c2b1692cfe1d14a6 to your computer and use it in GitHub Desktop.
Listing EC2 instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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