Class: Aws::AssumeRoleCredentials

Inherits:
Credentials show all
Defined in:
aws-sdk-core/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 inherited from Credentials

#access_key_id, #secret_access_key, #session_token

Instance Method Summary collapse

Methods inherited from Credentials

#set?

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)

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

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

Instance Attribute Details

#clientSTS::Client (readonly)

Returns:

  • (STS::Client)

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

def client
  @client
end