Sha256: e32a010dc22f8e11668643ee72027cd971a7c7d32014e5a232344a8977af8cdd

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

require 'open-uri'

module EY
  class Metadata
    # An adapter that reads from Amazon EC2's metadata web service, which is only available from cloud instances.
    class AmazonEc2Api
      # The present instance's Amazon Ec2 instance id.
      def present_instance_id
        @present_instance_id ||= open('http://169.254.169.254/latest/meta-data/instance-id').read
      end

      # The present instance's Amazon Ec2 security group.
      def present_security_group
        @present_security_group ||= open('http://169.254.169.254/latest/meta-data/security-groups').read
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
engineyard-metadata-0.2.4 lib/engineyard-metadata/amazon_ec2_api.rb