Class: Aws::AssumeRoleCredentials

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

Overview

An auto-refreshing credential provider that works by assuming a role via STS::Client#assume_role.

role_credentials = Aws::AssumeRoleCredentials.new(
  client: Aws::STS::Client.new(...),
  role_arn: "linked::account::arn",
  role_session_name: "session-name"
)

ec2 = Aws::EC2::Client.new(credentials: role_credentials)

If you omit ‘:client` option, a new STS::Client object will be constructed.

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 = {}) ⇒ AssumeRoleCredentials

Returns a new instance of AssumeRoleCredentials.

Parameters:

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

    a customizable set of options

  • opitons (Hash)

    a customizable set of options

Options Hash (options):

  • :role_arn (required, String)
  • :role_session_name (required, String)
  • :policy (String)
  • :duration_seconds (Integer)
  • :external_id (String)


27
28
29
30
31
# File 'lib/aws-sdk-core/assume_role_credentials.rb', line 27

def initialize(options = {})
  @options = options.dup
  @client = @options.delete(:client) || STS::Client.new
  super
end

Instance Attribute Details

#clientSTS::Client (readonly)

Returns:

  • (STS::Client)


34
35
36
# File 'lib/aws-sdk-core/assume_role_credentials.rb', line 34

def client
  @client
end