class Aws::AssumeRoleCredentials

@see Aws::STS::Client#assume_role
constructed with additional options that were provided.
If you omit ‘:client` option, a new {Aws::STS::Client} object will be
ec2 = Aws::EC2::Client.new(credentials: role_credentials)
)
role_session_name: “session-name”
role_arn: “linked::account::arn”,
client: Aws::STS::Client.new(…),
role_credentials = Aws::AssumeRoleCredentials.new(
{Aws::STS::Client#assume_role}.
An auto-refreshing credential provider that assumes a role via

def assume_role_options

Other tags:
    Api: - private
def assume_role_options
  @aro ||= begin
    input = STS::Client.api.operation(:assume_role).input
    Set.new(input.shape.member_names)
  end
end

def initialize(options = {})

Options Hash: (**options)
  • before_refresh (Callable) -- Proc called before
  • :client (STS::Client) --
  • :external_id (String) --
  • :duration_seconds (Integer) --
  • :policy (String) --
  • :role_session_name (required, String) --
  • :role_arn (required, String) --
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
    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

def parse_account_id(resp)

def parse_account_id(resp)
  arn = resp.assumed_role_user&.arn
  ARNParser.parse(arn).account_id if ARNParser.arn?(arn)
end

def refresh

def refresh
  resp = @client.assume_role(@assume_role_params)
  creds = resp.credentials
  @credentials = Credentials.new(
    creds.access_key_id,
    creds.secret_access_key,
    creds.session_token,
    account_id: parse_account_id(resp)
  )
  @expiration = creds.expiration
end