Skip to content

Instantly share code, notes, and snippets.

@SaschaMoellering
Created May 26, 2014 15:27
Show Gist options
  • Save SaschaMoellering/5e8a22d986b6c938dc00 to your computer and use it in GitHub Desktop.
Save SaschaMoellering/5e8a22d986b6c938dc00 to your computer and use it in GitHub Desktop.
require 'net/http'
link = URI.parse('http://169.254.169.254/latest/meta-data/instance-id')
request = Net::HTTP::Get.new(link.path)
begin
response = Net::HTTP.start(link.host, link.port) { |http|
http.read_timeout = 5 #Default is 60 seconds
http.request(request)
}
rescue Net::ReadTimeout => e
puts e.message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment