class AwsAssumeRole::Credentials::Providers::AssumeRoleCredentials

Constants

STS_KEYS

@option options [required, String] :role_arn @option options [required, String] :role_session_name @option options [String] :policy @option options [Integer] :duration_seconds @option options [String] :external_id @option options [STS::Client] :client

Attributes

client[R]

@return [STS::Client]

Public Class Methods

new(options = {}) click to toggle source
# File lib/aws_assume_role/credentials/providers/assume_role_credentials.rb, line 21
def initialize(options = {})
    client_opts = {}
    @assume_role_params = {}
    options.each_pair do |key, value|
        if self.class.assume_role_options.include?(key)
            @assume_role_params[key] = value
        else
            next unless STS_KEYS.include?(key)
            client_opts[key] = value
        end
    end
    @client = client_opts[:client] || ::Aws::STS::Client.new(client_opts)
    super
end

Private Class Methods

assume_role_options() click to toggle source

@api private

# File lib/aws_assume_role/credentials/providers/assume_role_credentials.rb, line 53
def assume_role_options
    @aro ||= begin
        input = ::Aws::STS::Client.api.operation(:assume_role).input
        Set.new(input.shape.member_names)
    end
end

Private Instance Methods

refresh() click to toggle source
# File lib/aws_assume_role/credentials/providers/assume_role_credentials.rb, line 41
def refresh
    c = @client.assume_role(@assume_role_params).credentials
    @credentials = ::Aws::Credentials.new(
        c.access_key_id,
        c.secret_access_key,
        c.session_token,
    )
    @expiration = c.expiration
end