module Fog::AWS::CredentialFetcher::ConnectionMethods

Public Instance Methods

refresh_credentials_if_expired() click to toggle source
# File lib/fog/aws/credential_fetcher.rb, line 120
def refresh_credentials_if_expired
  refresh_credentials if credentials_expired?
end

Private Instance Methods

credentials_expired?() click to toggle source
# File lib/fog/aws/credential_fetcher.rb, line 133
def credentials_expired?
  @use_iam_profile &&
    (!@aws_credentials_expire_at ||
     (@aws_credentials_expire_at && Fog::Time.now > @aws_credentials_expire_at - credentials_refresh_threshold)) #new credentials become available from around 5 minutes before expiration time
end
credentials_refresh_threshold() click to toggle source

When defined, 'aws_credentials_refresh_threshold_seconds' controls when the credential needs to be refreshed, expressed in seconds before the current credential's expiration time

# File lib/fog/aws/credential_fetcher.rb, line 129
def credentials_refresh_threshold
  @aws_credentials_refresh_threshold_seconds || 15
end
refresh_credentials() click to toggle source
# File lib/fog/aws/credential_fetcher.rb, line 139
def refresh_credentials
  if @use_iam_profile
    new_credentials = service.fetch_credentials :use_iam_profile => @use_iam_profile, :region => @region
    if new_credentials.any?
      setup_credentials new_credentials
      return true
    else
      false
    end
  else
    false
  end
end