1

我有以下代码:

require 'rubygems'
require 'aws-sdk'
require 'sqlite3'
require 'active_record'

db = SQLite3::Database.new('awsec2.db')

ActiveRecord::Base.establish_connection(
  :adapter=> "sqlite3",
  :database=> "awsec2")

ActiveRecord::Schema.define do
  create_table :instances do |t|
   t.column :instance_id, :string
   t.column :status, :string
  end
end


ACCESS_KEY_ID = '.......................'
SECRET_ACCESS_KEY = '....................'

ec2 = AWS::EC2.new(:access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)

ec2.instances.inject({}) { |m, i| m[i.id] = i.status; m } # How to pass those items to the instances table

如何将ec2.instances方法收集的数据存储到数据库表中?

4

1 回答 1

0

这是亚马逊制作的元数据查询工具。它只是一个从元数据 url获取数据的帮助脚本。

于 2012-06-29T01:19:52.510 回答