Class: AWS.MetadataService

Inherits:
Object
  • Object
show all
Defined in:
lib/metadata_service.js

Overview

Note:

This feature is not supported in the browser environment of the SDK.

Represents a metadata service available on EC2 instances. Using the request() method, you can receieve metadata about any available resource on the metadata service.

Constructor Summary collapse

Property Summary collapse

Method Summary collapse

Constructor Details

new AWS.MetadataService(options) ⇒ void

Creates a new MetadataService object with a given set of options.

Options Hash (options):

  • host (String)

    the hostname of the instance metadata service

  • httpOptions (map)

    a map of options to pass to the underlying HTTP request:

    • timeout (Number) — a timeout value in milliseconds to wait before aborting the connection. Set to 0 for no timeout.
  • maxRetries (Integer)

    the maximum number of retries to perform for timeout errors

  • retryDelayOptions (map)

    A set of options to configure the retry delay on retryable errors. See AWS.Config for details.

Property Details

hostString (static, readwrite)

Default Value:

AWS.MetadataService.host = '169.254.169.254'

httpOptionsmap (readwrite)

Returns a map of options to pass to the underlying HTTP request:

  • timeout (Number) — a timeout value in milliseconds to wait before aborting the connection. Set to 0 for no timeout.

Returns:

  • (map)

    a map of options to pass to the underlying HTTP request:

    • timeout (Number) — a timeout value in milliseconds to wait before aborting the connection. Set to 0 for no timeout.

Method Details

request(path, callback) ⇒ void

Sends a request to the instance metadata service for a given resource.

Parameters:

  • path (String)

    the path of the resource to get

Callback (callback):

  • function(err, data) { ... }

    Called when a response is available from the service.

    Parameters:

    • err (Error, null)

      if an error occurred, this value will be set

    • data (String, null)

      if the request was successful, the body of the response