New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

route53-updater

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

route53-updater - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

114

index.js

@@ -7,3 +7,3 @@ var assert = require("assert-plus");

function retrieveHostedZone(name, cb) {
function retrieveHostedZoneId(name, cb) {
"use strict";

@@ -13,3 +13,3 @@ assert.string(name, "name");

var route53 = new AWS.Route53(),
hostedZone,
hostedZones = [],
nextMarker;

@@ -21,5 +21,2 @@ async.whilst(

}
if (hostedZone !== undefined) {
return false;
}
return true;

@@ -35,5 +32,5 @@ },

} else {
hostedZone = underscore.find(res.HostedZones, function(hostedZone) {
hostedZones = hostedZones.concat(underscore.filter(res.HostedZones, function(hostedZone) {
return hostedZone.Name === name;
});
}));
if (res.IsTruncated === true) {

@@ -52,3 +49,10 @@ nextMarker = res.NextMarker;

} else {
cb(undefined, hostedZone);
if (hostedZones.length > 1) {
cb(new Error("hostedZoneName not unique. Use hostedZoneId parameter."));
} else if (hostedZones.length === 1) {
cb(undefined, hostedZones[0].Id);
} else {
cb(new Error("hostedZoneName not found"));
}
}

@@ -218,6 +222,45 @@ }

function run(action, params, cb) {
function run(action, hostedZoneId, params, cb) {
"use strict";
if (action === "CREATE" || action === "UPDATE") {
var issueUpdate = function(err, value) {
if (err) {
cb(err);
} else {
if (action === "CREATE") {
createRecordSet(hostedZoneId, params.recordSetName, params.type || "CNAME", value, params.ttl || 60, cb);
} else if (action === "UPDATE") {
updateRecordSet(hostedZoneId, params.recordSetName, params.type || "CNAME", value, params.ttl || 60, cb);
}
}
};
if (params.iface){
var ifaces = os.networkInterfaces();
var iface = ifaces[params.iface];
if (iface === undefined) {
cb(new Error("interface not found"));
} else {
assert.arrayOfObject(iface, "iface present");
var ipv4 = underscore.find(iface, function(binding) { return binding.family === "IPv4"; });
if (ipv4 === undefined) {
cb(new Error("interface has no IPv4 address"));
} else {
issueUpdate(null, ipv4.address);
}
}
} else {
var mds = new AWS.MetadataService();
mds.request("/latest/meta-data/" + (params.metadata || "public-hostname"), issueUpdate);
}
} else if (action === "DELETE") {
deleteRecordSet(hostedZoneId, params.recordSetName, cb);
} else {
cb(new Error("action must be one of CREATE, UPDATE, or DELETE"));
}
}
function input(action, params, cb) {
"use strict";
assert.string(action, "action");
assert.string(params.hostedZoneName, "params.hostedZoneName");
assert.optionalString(params.hostedZoneId, "params.hostedZoneId");
assert.string(params.recordSetName, "params.recordSetName");

@@ -229,45 +272,18 @@ assert.optionalNumber(params.ttl, "params.ttl");

assert.func(cb, "cb");
retrieveHostedZone(params.hostedZoneName, function(err, hostedZone) {
if (err) {
cb(err);
} else {
if (hostedZone === undefined) {
cb(new Error("hostedZoneName not found"));
if (params.hostedZoneId !== undefined) {
run(action, params.hostedZoneId, params, cb);
} else {
assert.string(params.hostedZoneName, "params.hostedZoneName");
retrieveHostedZoneId(params.hostedZoneName, function(err, hostedZoneId) {
if (err) {
cb(err);
} else {
if (action === "CREATE" || action === "UPDATE") {
var issueUpdate = function(err, value) {
if (err) {
cb(err);
} else {
if (action === "CREATE") {
createRecordSet(hostedZone.Id, params.recordSetName, params.type || "CNAME", value, params.ttl || 60, cb);
} else if (action === "UPDATE") {
updateRecordSet(hostedZone.Id, params.recordSetName, params.type || "CNAME", value, params.ttl || 60, cb);
}
}
};
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") {
deleteRecordSet(hostedZone.Id, params.recordSetName, cb);
} else {
cb(new Error("action must be one of CREATE, UPDATE, DELETE"));
}
run(action, hostedZoneId, params, cb);
}
}
});
});
}
}
module.exports = run;
exports.retrieveHostedZone = retrieveHostedZone;
module.exports = input;
exports.retrieveHostedZoneId = retrieveHostedZoneId;
exports.retrieveRecordSet = retrieveRecordSet;

@@ -274,0 +290,0 @@ exports.deleteRecordSet = deleteRecordSet;

{
"name": "route53-updater",
"version": "0.3.0",
"version": "1.0.0",
"description": "Updating a Route53 resource set with meta-data of EC2 instance",

@@ -13,12 +13,13 @@ "keywords": ["Route53", "AWS"],

"dependencies": {
"assert-plus": "0.1.5",
"aws-sdk": "2.1.20",
"async": "0.9.0",
"underscore": "1.8.2",
"minimist": "1.1.1"
"assert-plus": "1.0.0",
"aws-sdk": "2.4.1",
"async": "1.5.2",
"underscore": "1.8.3",
"minimist": "1.2.0"
},
"devDependencies": {
"jshint": "2.6.3",
"madge": "0.4.1",
"npmedge": "0.2.1"
"jshint": "2.9.2",
"madge": "0.5.4",
"npmedge": "0.2.2",
"istanbul": "0.4.4"
},

@@ -25,0 +26,0 @@ "repository": {

@@ -7,12 +7,8 @@ [![Build Status](https://secure.travis-ci.org/widdix/node-route53-updater.png)](http://travis-ci.org/widdix/node-route53-updater)

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.
The `route53-updater` module can update a Route 53 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
## Usage
Add `"route53:GetChange"` to the IAM access rights.
## CLI Usage
Install route53-updater globally

@@ -26,2 +22,6 @@

or
route53-updater --action UPDATE --hostedZoneId XXXXXXXXXXXXX --recordSetName test.yourdomain.com.
The assumed defaults are

@@ -58,10 +58,22 @@

* `action`: String
* `action`: String (required)
* `UPDATE`: Update the DNS entry (delete if exists, and create)
* `DELETE`: Create the DNS entry
* `CREATE`: Create the DNS entry or fail if existing
* `hostedZoneName`: String - Name of your hosted zone (Must end with an dot!)
* `recordSetName`: String - Name of your record set (XYZ.hostedZoneName)
* `ttl`: Number - TTL in seconds (default 60)
* `metadata`: String - Metadata field to ue als the value (default public-hostname, http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html )
* `type`: String - Type of record set (default CNAME, http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html )
* `hostedZoneName`: String (either `hostedZoneName` or `hostedZoneId` is required) - Name of your hosted zone (Must end with an dot!)
* `hostedZoneId`: String (either `hostedZoneName` or `hostedZoneId` is required) - Id of your hosted zone
* `recordSetName`: String (required) - Name of your record set (XYZ.hostedZoneName)
* `ttl`: Number (optional, default 60) - TTL in seconds
* `metadata`: String (optional, default public-hostname) - Metadata field to use as the value (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html)
* `type`: String (optional, default CNAME) - Type of record set (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html)
## Breaking changes
### Update from 0.2.X to 1.0.X
No breaking changes!
### Update from 0.1.X to 0.2.X
Added `"route53:GetChange"` to the IAM access rights.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc