Class Credentials

Credentials class.

Manually sets credentials. Also the base class for all credential classes.

Functions

aws:Credentials (opt) Constructor.

Methods

credentials:get () Gets credentials, refreshes if required.
credentials:needsRefresh () checks whether credentials have expired.
credentials:refresh () updates credentials.
credentials:set (accessKeyId, secretAccessKey, sessionToken, expireTime) Sets credentials.


Functions

aws:Credentials (opt)
Constructor.

Parameters:

  • opt options table
    • expiryWindow number (default 15) of seconds before expiry to start refreshing
    • accessKeyId (optional) only specify if you manually specify credentials
    • secretAccessKey (optional) only specify if you manually specify credentials
    • sessionToken (optional) only specify if you manually specify credentials
    • expireTime (optional, number (epoch) or string (rfc3339)). This should not be specified. Default: If any of the 3 secrets are given; 10yrs, otherwise 0 (forcing a refresh on the first call to get).

Usage:

    local my_creds = aws:Credentials {
      accessKeyId = "access",
      secretAccessKey = "secret",
      sessionToken = "token",
    }
    
    local success, id, secret, token = my_creds:get()

Methods

credentials:get ()
Gets credentials, refreshes if required. Returns credentials, doesn't take a callback like AWS SDK.

When a refresh is executed, it will be done within a semaphore to prevent many simultaneous refreshes.

Returns:

    success(true) + accessKeyId + secretAccessKey + sessionToken + expireTime or success(false) + error
credentials:needsRefresh ()
checks whether credentials have expired.

Returns:

    boolean
credentials:refresh ()
updates credentials. override in subclasses, should call set to set the properties.

Returns:

    success, or nil+err
credentials:set (accessKeyId, secretAccessKey, sessionToken, expireTime)
Sets credentials. additional to AWS SDK

Parameters:

  • accessKeyId
  • secretAccessKey
  • sessionToken
  • expireTime (optional) number (unix epoch based), or string (valid rfc 3339)

Returns:

    true
generated by LDoc 1.5.0 Last updated 2024-09-23 09:29:37