DynamoDBHelper.prototype.getDynamoDB = function()

in source/shared-modules/dynamodb-helper/dynamodb-helper.js [237:262]


DynamoDBHelper.prototype.getDynamoDB = function(credentials, callback) {
    try {
        var creds = {
            accessKeyId: credentials.claim.AccessKeyId,
            secretAccessKey: credentials.claim.SecretKey,
            sessionToken: credentials.claim.SessionToken,
            region: configuration.aws_region
        }

        var ddb = new AWS.DynamoDB(creds);
        if (!this.tableExists) {
            this.createTable(ddb, function (error) {
                if (error) {
                    callback(error);
                } else {
                    this.tableExists = true;
                    callback(null, ddb);
                }
            }.bind(this));
        } else {
            callback(null, ddb);
        }
    } catch (error) {
        callback(error);
    }
}