We announced the upcoming end-of-support for AWS SDK for JavaScript v2.
We recommend that you migrate to AWS SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.

Class: AWS.RDS.Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/rds/signer.js

Overview

A signer object can be used to generate an auth token to a database.

Constructor Summary collapse

Method Summary collapse

Constructor Details

new AWS.RDS.Signer(options) ⇒ void

Creates a signer object can be used to generate an auth token.

Examples:

Passing in options to constructor

var signer = new AWS.RDS.Signer({
  credentials: new AWS.SharedIniFileCredentials({profile: 'default'}),
  region: 'us-east-1',
  hostname: 'db.us-east-1.rds.amazonaws.com',
  port: 8000,
  username: 'name'
});

Options Hash (options):

  • credentials (AWS.Credentials)

    the AWS credentials to sign requests with. Uses the default credential provider chain if not specified.

  • hostname (String)

    the hostname of the database to connect to.

  • port (Number)

    the port number the database is listening on.

  • region (String)

    the region the database is located in.

  • username (String)

    the username to login as.

Method Details

getAuthToken(options = {}, [callback]) ⇒ String?

Note:

You must ensure that you have static or previously resolved credentials if you call this method synchronously (with no callback), otherwise it may not properly sign the request. If you cannot guarantee this (you are using an asynchronous credential provider, i.e., EC2 IAM roles), you should always call this method with an asynchronous callback.

Generate an auth token to a database.

Examples:

Generating an auth token synchronously

var signer = new AWS.RDS.Signer({
  // configure options
  region: 'us-east-1',
  username: 'default',
  hostname: 'db.us-east-1.amazonaws.com',
  port: 8000
});
var token = signer.getAuthToken({
  // these options are merged with those defined when creating the signer, overriding in the case of a duplicate option
  // credentials are not specified here or when creating the signer, so default credential provider will be used
  username: 'test' // overriding username
});

Generating an auth token asynchronously

var signer = new AWS.RDS.Signer({
  // configure options
  region: 'us-east-1',
  username: 'default',
  hostname: 'db.us-east-1.amazonaws.com',
  port: 8000
});
signer.getAuthToken({
  // these options are merged with those defined when creating the signer, overriding in the case of a duplicate option
  // credentials are not specified here or when creating the signer, so default credential provider will be used
  username: 'test' // overriding username
}, function(err, token) {
  if (err) {
    // handle error
  } else {
    // use token
  }
});

Parameters:

  • options (map) (defaults to: {})

    The fields to use when generating an auth token. Any options specified here will be merged on top of any options passed to AWS.RDS.Signer:

    • credentials (AWS.Credentials) — the AWS credentials to sign requests with. Uses the default credential provider chain if not specified.
    • hostname (String) — the hostname of the database to connect to.
    • port (Number) — the port number the database is listening on.
    • region (String) — the region the database is located in.
    • username (String) — the username to login as.

Callback (callback):

  • function(err, token) { ... }

    If a callback is supplied, it is called when an auth token has been generated.

    Parameters:

    • err (Error)

      the error object returned from the signer.

    • token (String)

      the auth token.

Returns:

  • (String)

    if called synchronously (with no callback), returns the auth token.

  • (null)

    nothing is returned if a callback is provided.