这是正确的方法吗?如果还有其他更好的方法可以帮忙吗?
#! /usr/bin/ruby
require 'aws-sdk'
client = Aws::EC2::Client.new(region: 'us-west-2')
resp = client.describe_instances
resp.reservations.each do |node, num = 0|
puts "#{node.instances[num].instance_id}"
end
答案 0 :(得分:0)
credential = {
access_key_id: 'xxxxxxxxxxxxxxxxxxxx',
secret_access_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
region: 'us-west-2'
}
Aws.config.update aws_credential
Aws::EC2::Client.new.describe_instances.reservations.each do |instance|
p instance[0].instance_id
end