route53-updater
Advanced tools
35
index.js
@@ -74,2 +74,28 @@ var assert = require("assert-plus"); | ||
function checkINSYNC(changeInfo, cb) { | ||
"use strict"; | ||
assert.object(changeInfo, "changeInfo"); | ||
assert.string(changeInfo.Id, "changeInfo.Id"); | ||
assert.string(changeInfo.Status, "changeInfo.Status"); | ||
assert.func(cb, "cb"); | ||
if (changeInfo.Status === "PENDING") { | ||
setTimeout(function() { | ||
var route53 = new AWS.Route53(); | ||
route53.getChange({ | ||
"Id": changeInfo.Id | ||
}, function(err ,res) { | ||
if (err) { | ||
cb(err); | ||
} else { | ||
checkINSYNC(res.ChangeInfo, cb); | ||
} | ||
}); | ||
}, 5000); | ||
} else if (changeInfo.Status === "INSYNC") { | ||
cb(); | ||
} else { | ||
cb(new Error("unsupported status " + changeInfo.Status)); | ||
} | ||
} | ||
function deleteRecordSet(hostedZoneId, name, cb) { | ||
@@ -98,3 +124,3 @@ "use strict"; | ||
} else { | ||
cb(); | ||
checkINSYNC(res.ChangeInfo, cb); | ||
} | ||
@@ -133,7 +159,5 @@ }); | ||
if (err) { | ||
console.log("err", err); | ||
cb(err); | ||
} else { | ||
console.log("res", res); | ||
cb(undefined); | ||
checkINSYNC(res.ChangeInfo, cb); | ||
} | ||
@@ -184,3 +208,3 @@ }); | ||
} else { | ||
cb(); | ||
checkINSYNC(res.ChangeInfo, cb); | ||
} | ||
@@ -201,3 +225,2 @@ }); | ||
assert.func(cb, "cb"); | ||
retrieveHostedZone(params.hostedZoneName, function(err, hostedZone) { | ||
@@ -204,0 +227,0 @@ if (err) { |
{ | ||
"name": "route53-updater", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Updating a Route53 resource set with meta-data of EC2 instance", | ||
@@ -14,6 +14,6 @@ "keywords": ["Route53", "AWS"], | ||
"assert-plus": "0.1.5", | ||
"aws-sdk": "2.1.16", | ||
"aws-sdk": "2.1.20", | ||
"async": "0.9.0", | ||
"underscore": "1.8.2", | ||
"minimist": "1.1.0" | ||
"minimist": "1.1.1" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
@@ -7,6 +7,10 @@ [](http://travis-ci.org/widdix/node-route53-updater) | ||
The `route53-updater` module can update an Record Set with the current IP of an machine. This can be useful if you have a single instance running in an auto scaling group. During startup of the EC2 instance you call the `route53-updater` to update the DNS entry to the new IP. | ||
The `route53-updater` module can update an Record Set with the current IP or hostname of an machine. This can be useful if you have a single instance running in an auto scaling group. During startup of the EC2 instance you call the `route53-updater` to update the DNS entry to the new IP. | ||
Port of https://github.com/taimos/route53-updater/ | ||
## Update from 0.1.X to 0.2.X | ||
Add `"route53:GetChange"` to the IAM access rights. | ||
## CLI Usage | ||
@@ -18,3 +22,3 @@ | ||
Create or update the DNS A entry for test.yourdomain.com to point to the public ip of the EC2 instance | ||
Create or update the DNS CNAME entry for test.yourdomain.com to point to the public hostname of the EC2 instance | ||
@@ -38,3 +42,4 @@ route53-updater --action UPDATE --hostedZoneName yourdomain.com. --recordSetName test.yourdomain.com. | ||
"route53:ListHostedZones", | ||
"route53:ListResourceRecordSets" | ||
"route53:ListResourceRecordSets", | ||
"route53:GetChange" | ||
], | ||
@@ -41,0 +46,0 @@ "Resource": [ |
11670
7.17%260
9.7%61
8.93%