Created
October 5, 2019 23:14
-
-
Save andreigec/ce9a1793c6122133dbf0e0f0476b5dd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require("aws-sdk") | |
var accessKeyId = "AAA" | |
var secretAccessKey = "BBB" | |
var route53 = {} | |
var hz = "XXX" | |
var name = "ZZZ" | |
var update = async (ip, hz, name) => { | |
return new Promise((res, rej) => { | |
var params = { | |
ChangeBatch: { | |
Changes: [ | |
{ | |
Action: "UPSERT", | |
ResourceRecordSet: { | |
Name: name, | |
ResourceRecords: [ | |
{ Value: ip } | |
], | |
TTL: 60, | |
Type: "A" | |
} | |
} | |
], | |
Comment: "auto ip update" | |
}, | |
HostedZoneId: hz | |
} | |
route53.changeResourceRecordSets(params, (err, data) => { | |
console.log("err=", err) | |
console.log("Data=", data) | |
if (err) { | |
rej(err) | |
} else { | |
res(data) | |
} | |
}) | |
}) | |
} | |
var main = async ([, , ip]) => { | |
var creds = { | |
accessKeyId, | |
secretAccessKey | |
} | |
AWS.config.credentials = new AWS.Credentials(creds); | |
route53 = new AWS.Route53(creds); | |
console.log("ip=", ip) | |
await update(ip, hz, name) | |
} | |
main(process.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment