Sha256: 03951832dd0024f80af059bb45e8f9c43cf65972f23b2c6e65f01482fcdceca9

Contents?: true

Size: 550 Bytes

Versions: 6

Compression:

Stored size: 550 Bytes

Contents

require 'open-uri'

module EY
  module 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
        open("http://169.254.169.254/latest/meta-data/instance-id").gets
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
engineyard-metadata-0.1.2 lib/engineyard-metadata/amazon_ec2_api.rb
engineyard-metadata-0.1.1 lib/engineyard-metadata/amazon_ec2_api.rb
engineyard-metadata-0.1.0 lib/engineyard-metadata/amazon_ec2_api.rb
engineyard-metadata-0.0.7 lib/engineyard-metadata/amazon_ec2_api.rb
engineyard-metadata-0.0.6 lib/engineyard-metadata/amazon_ec2_api.rb
engineyard-metadata-0.0.5 lib/engineyard-metadata/amazon_ec2_api.rb