12Nov/090
Get the EC2 Instance ID for this (current) machine in Ruby
On Amazon EC2, if you are in ruby, and you want to get the current Instance ID for the machine you are running the script from, here is one way you can do it.
require 'net/http' instance_id = Net::HTTP.get URI.parse('http://169.254.169.254/2009-04-04/meta-data/instance-id');
we are using 2009-04-04 API there. If you want to see if there is a more recent version, you can do this on the command line:
wget http://169.254.169.254
and replace the 2009-04-04. with whatever versions are listed.