-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
44 lines (37 loc) · 1.15 KB
/
update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
process.env.NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
var config = require('devbox-config').get('aws-route53-updater'),
AWS = require('aws-sdk'),
ipify = require('ipify');
AWS.config.update({
accessKeyId: config.aws.id,
secretAccessKey: config.aws.secret,
region: config.aws.region
});
var route53 = new AWS.Route53();
ipify(function(err, ip){
if (err) return console.error(err);
var params = {
ChangeBatch: {
Changes: [
{
Action: 'UPSERT',
ResourceRecordSet: {
Name: 'home.devbox.com.',
Type: 'A',
ResourceRecords: [
{
Value: ip
}
],
TTL: 3600
}
}
]
},
HostedZoneId: 'Z3VW1N2MWG2SOR'
};
route53.changeResourceRecordSets(params, function(err, data) {
if (err) return console.log(err, err.stack);
console.log('updated resource');
});
});