module Awsmeta::Extras::Discovery

useful extras that help with integration

Public Instance Methods

ec2?() click to toggle source

check for if code is executing on an ec2 instance

# File lib/awsmeta/extras/discovery.rb, line 11
def ec2?
  return false if ENV['AWSMETA_DISABLE_EC2_DISCOVERY'] == 'true'

  !Awsmeta.instance_id.nil?
rescue Net::OpenTimeout,
       Errno::EHOSTUNREACH,
       Awsmeta::Errors::ResourceNotFound
  false
end