validate route53 credentials

This commit is contained in:
Girish Ramakrishnan
2016-07-03 21:37:17 -05:00
parent 21c5491717
commit ab1b5f89a1
2 changed files with 72 additions and 8 deletions
+20 -1
View File
@@ -5,7 +5,10 @@ exports = module.exports = {
get: get,
del: del,
update: update,
getChangeStatus: getChangeStatus
getChangeStatus: getChangeStatus,
// not part of "dns" interface
getHostedZone: getHostedZone
};
var assert = require('assert'),
@@ -50,6 +53,22 @@ function getZoneByName(dnsConfig, zoneName, callback) {
});
}
function getHostedZone(dnsConfig, zoneName, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof zoneName, 'string');
assert.strictEqual(typeof callback, 'function');
getZoneByName(dnsConfig, zoneName, function (error, zone) {
var route53 = new AWS.Route53(getDnsCredentials(dnsConfig));
route53.getHostedZone({ Id: zone.Id }, function (error, result) {
if (error && error.code === 'AccessDenied') return callback(new SubdomainError(SubdomainError.ACCESS_DENIED, error.message));
if (error) return callback(new SubdomainError(SubdomainError.EXTERNAL_ERROR, error.message));
callback(null, result);
});
});
}
function add(dnsConfig, zoneName, subdomain, type, values, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof zoneName, 'string');