Skip to content

Instantly share code, notes, and snippets.

@popowa
Created May 16, 2013 06:05
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 popowa/5589698 to your computer and use it in GitHub Desktop.
Save popowa/5589698 to your computer and use it in GitHub Desktop.
EBSボリュームと、それに紐付くEC2インスタンスの一覧を出力する
require 'rubygems'
require 'yaml'
require 'aws-sdk'
AWS.config({
:access_key_id => 'XXXXXXXXXXXXXXXXXXXXXXX',
:secret_access_key => 'XXXXXXXXXXXXXXXXXXXXXXX',
:ec2_endpoint => 'ec2.ap-northeast-1.amazonaws.com'
})
ec2 = AWS::EC2.new
ec2.volumes.each { |volume|
instance_id = nil
volume.attachments.each {|attachment|
instance_id = attachment.instance.id
}
puts "#{volume.id},#{volume.tags["Name"]}, #{volume.status}, #{volume.size}GB => #{instance_id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment