Class: Aws::InstanceProfileCredentials

Inherits:
Object
  • Object
show all
Includes:
CredentialProvider, RefreshingCredentials
Defined in:
lib/aws-sdk-core/instance_profile_credentials.rb

Defined Under Namespace

Classes: Non200Response, Token, TokenExpiredError, TokenRetrivalError, TokenRetrivalUnavailableError

Constant Summary collapse

NETWORK_ERRORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

These are the errors we trap when attempting to talk to the instance metadata service. Any of these imply the service is not present, no responding or some other non-recoverable error.

[
  Errno::EHOSTUNREACH,
  Errno::ECONNREFUSED,
  Errno::EHOSTDOWN,
  Errno::ENETUNREACH,
  SocketError,
  Timeout::Error,
  Non200Response,
]
METADATA_PATH_BASE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Path base for GET request for profile and credentials

'/latest/meta-data/iam/security-credentials/'
METADATA_TOKEN_PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Path for PUT request for token

'/latest/api/token'

Instance Attribute Summary collapse

Attributes included from CredentialProvider

#credentials

Instance Method Summary collapse

Methods included from RefreshingCredentials

#credentials, #expiration, #refresh!

Methods included from CredentialProvider

#access_key_id, #secret_access_key, #session_token, #set?

Methods included from Deprecations

#deprecated

Constructor Details

#initialize(options = {}) ⇒ InstanceProfileCredentials

Returns a new instance of InstanceProfileCredentials.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :retries (Integer) — default: 5

    Number of times to retry when retrieving credentials.

  • :ip_address (String) — default: '169.254.169.254'
  • :port (Integer) — default: 80
  • :http_open_timeout (Float) — default: 5
  • :http_read_timeout (Float) — default: 5
  • :delay (Numeric, Proc)

    By default, failures are retried with exponential back-off, i.e. ‘sleep(1.2 ** num_failures)`. You can pass a number of seconds to sleep between failed attempts, or a Proc that accepts the number of failures.

  • :http_debug_output (IO) — default: nil

    HTTP wire traces are sent to this object. You can specify something like $stdout.

  • :token_ttl (Integer) — default: 21600

    Time-to-Live in seconds for EC2 Metadata Token used for fetching Metadata Profile Credentials.



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 62

def initialize options = {}
  @retries = options[:retries] || 5
  @ip_address = options[:ip_address] || '169.254.169.254'
  @port = options[:port] || 80
  @http_open_timeout = options[:http_open_timeout] || 5
  @http_read_timeout = options[:http_read_timeout] || 5
  @http_debug_output = options[:http_debug_output]
  @backoff = backoff(options[:backoff])
  @token_ttl = options[:token_ttl] || 21600
  super
end

Instance Attribute Details

#retriesInteger (readonly)

Returns Number of times to retry when retrieving credentials from the instance metadata service. Defaults to 0 when resolving from the default credential chain (CredentialProviderChain).

Returns:

  • (Integer)

    Number of times to retry when retrieving credentials from the instance metadata service. Defaults to 0 when resolving from the default credential chain (CredentialProviderChain).



77
78
79
# File 'lib/aws-sdk-core/instance_profile_credentials.rb', line 77

def retries
  @retries
end