route53-updater
Advanced tools
Comparing version 0.2.0 to 0.3.0
19
index.js
@@ -5,2 +5,3 @@ var assert = require("assert-plus"); | ||
var underscore = require("underscore"); | ||
var os = require("os"); | ||
@@ -221,2 +222,3 @@ function retrieveHostedZone(name, cb) { | ||
assert.optionalString(params.type, "params.type"); | ||
assert.optionalString(params.iface, "params.iface"); | ||
assert.func(cb, "cb"); | ||
@@ -231,4 +233,3 @@ retrieveHostedZone(params.hostedZoneName, function(err, hostedZone) { | ||
if (action === "CREATE" || action === "UPDATE") { | ||
var mds = new AWS.MetadataService(); | ||
mds.request("/latest/meta-data/" + (params.metadata || "public-hostname"), function(err, value) { | ||
var issueUpdate = function(err, value) { | ||
if (err) { | ||
@@ -243,3 +244,15 @@ cb(err); | ||
} | ||
}); | ||
}; | ||
if(params.iface){ | ||
var iface = os.networkInterfaces()[params.iface]; | ||
assert.arrayOfObject(iface, "iface present"); | ||
var ipv4 = iface.filter(function(binding){ return binding.family === "IPv4"; }); | ||
assert.bool(ipv4.length === 1, "iface ipv4 family"); | ||
assert.string(ipv4[0].address, "iface ipv4 address"); | ||
issueUpdate(null, ipv4[0].address); | ||
}else{ | ||
var mds = new AWS.MetadataService(); | ||
mds.request("/latest/meta-data/" + (params.metadata || "public-hostname"), issueUpdate); | ||
} | ||
} else if (action === "DELETE") { | ||
@@ -246,0 +259,0 @@ deleteRecordSet(hostedZone.Id, params.recordSetName, cb); |
{ | ||
"name": "route53-updater", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Updating a Route53 resource set with meta-data of EC2 instance", | ||
@@ -26,3 +26,3 @@ "keywords": ["Route53", "AWS"], | ||
"type": "git", | ||
"url": "https://github.com/michaelwittig/node-route53-updater.git" | ||
"url": "https://github.com/widdix/node-route53-updater.git" | ||
}, | ||
@@ -29,0 +29,0 @@ "bin" : { |
@@ -29,2 +29,6 @@ [![Build Status](https://secure.travis-ci.org/widdix/node-route53-updater.png)](http://travis-ci.org/widdix/node-route53-updater) | ||
By default route53-updater will lookup the IP address against the Amazon Metadata Service. If running outside Amazon, you can use the first IPv4 address on an interface by specifying an --iface option | ||
route53-updater --action UPDATE --hostedZoneName yourdomain.com. --recordSetName test.yourdomain.com. --iface eth0 | ||
The instance running the script needs the following IAM access rights: | ||
@@ -31,0 +35,0 @@ |
12497
272
65