Class: Aws::ProcessCredentials

Inherits:
Object
  • Object
show all
Includes:
CredentialProvider
Defined in:
gems/aws-sdk-core/lib/aws-sdk-core/process_credentials.rb

Overview

A credential provider that executes a given process and attempts to read its stdout to receive a JSON payload containing the credentials.

credentials = Aws::ProcessCredentials.new(['/usr/bin/credential_proc'])
ec2 = Aws::EC2::Client.new(credentials: credentials)

Arguments should be provided as strings in the array, for example:

process = ['/usr/bin/credential_proc', 'arg1', 'arg2']
credentials = Aws::ProcessCredentials.new(process)
ec2 = Aws::EC2::Client.new(credentials: credentials)

Automatically handles refreshing credentials if an Expiration time is provided in the credentials payload.

Instance Attribute Summary

Attributes included from CredentialProvider

#credentials, #expiration

Instance Method Summary collapse

Methods included from CredentialProvider

#set?

Constructor Details

#initialize(process) ⇒ ProcessCredentials

Creates a new ProcessCredentials object, which allows an external process to be used as a credential provider.

Parameters:

  • process (Array<String>, String)

    An array of strings including the process name and its arguments to execute, or a single string to be executed by the shell (deprecated and insecure).



31
32
33
34
35
36
37
38
39
40
41
# File 'gems/aws-sdk-core/lib/aws-sdk-core/process_credentials.rb', line 31

def initialize(process)
  if process.is_a?(String)
    warn('Passing a single string to Aws::ProcessCredentials.new '\
         'is insecure, please use use an array of system arguments instead')
  end
  @process = process
  @credentials = credentials_from_process
  @async_refresh = false

  super
end