Skip to content

Instantly share code, notes, and snippets.

@SaschaMoellering
Created May 27, 2014 09:39
Show Gist options
  • Save SaschaMoellering/352d58bfa00be7cffbaf to your computer and use it in GitHub Desktop.
Save SaschaMoellering/352d58bfa00be7cffbaf to your computer and use it in GitHub Desktop.
0 require 'net/http'¬
1 ·¬
2 uri = URI.parse('http://169.254.169.254/latest/meta-data/instance-id')¬
3 ·¬
4 begin¬
5 Net::HTTP.start(uri.host, uri.port) do |http|¬
6 request = Net::HTTP::Get.new uri.request_uri¬
7 http.open_timeout = 5¬
8 respone = http.request request·¬
9 end¬
10 ·¬
11 rescue Exception => e·¬
12 puts e.message¬
13 puts e.class¬
14 end¬
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment