Class: Aws::AssumeRoleCredentials
- Inherits:
 - 
      Object
      
        
- Object
 - Aws::AssumeRoleCredentials
 
 
- Includes:
 - CredentialProvider, RefreshingCredentials
 
- Defined in:
 - gems/aws-sdk-core/lib/aws-sdk-core/assume_role_credentials.rb
 
Overview
An auto-refreshing credential provider that assumes 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 with additional options that were provided.
Constant Summary
Constants included from RefreshingCredentials
RefreshingCredentials::ASYNC_EXPIRATION_LENGTH, RefreshingCredentials::CLIENT_EXCLUDE_OPTIONS, RefreshingCredentials::SYNC_EXPIRATION_LENGTH
Instance Attribute Summary collapse
- 
  
    
      #assume_role_params  ⇒ Hash 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
 - 
  
    
      #client  ⇒ STS::Client 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
 
Attributes included from CredentialProvider
Instance Method Summary collapse
- 
  
    
      #initialize(options = {})  ⇒ AssumeRoleCredentials 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of AssumeRoleCredentials.
 
Methods included from RefreshingCredentials
Methods included from CredentialProvider
Constructor Details
#initialize(options = {}) ⇒ AssumeRoleCredentials
Returns a new instance of AssumeRoleCredentials.
      41 42 43 44 45 46 47 48 49 50 51 52 53 54 55  | 
    
      # File 'gems/aws-sdk-core/lib/aws-sdk-core/assume_role_credentials.rb', line 41 def initialize( = {}) client_opts = {} @assume_role_params = {} .each_pair do |key, value| if self.class..include?(key) @assume_role_params[key] = value elsif !CLIENT_EXCLUDE_OPTIONS.include?(key) client_opts[key] = value end end @client = client_opts[:client] || STS::Client.new(client_opts) @async_refresh = true @metrics = ['CREDENTIALS_STS_ASSUME_ROLE'] super end  | 
  
Instance Attribute Details
#assume_role_params ⇒ Hash (readonly)
      61 62 63  | 
    
      # File 'gems/aws-sdk-core/lib/aws-sdk-core/assume_role_credentials.rb', line 61 def assume_role_params @assume_role_params end  | 
  
#client ⇒ STS::Client (readonly)
      58 59 60  | 
    
      # File 'gems/aws-sdk-core/lib/aws-sdk-core/assume_role_credentials.rb', line 58 def client @client end  |