我有一个托管区域和记录集,可以路由到多个地址。我想通过在列表中添加或删除一个IP地址来更新记录集。如何使用AWS CLI(API)实现这一目标? 我尝试了下面的这个json请求,但它用新的(不更新)
替换了退出列表 applianc around autonom averag bath bedroom car charg drive eat home hour hous includ kilomet kitchen lap larg live mile over per pet road room second sedan size test up updat veri water
sentence 1: 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0
sentence 2: 0 0 0 0 0 0 1 0 0 0 0 2 0 0 1 0 0 0 0 1 0 2 0 0 0 1 0 0 0 0 0 0 0
sentence 3: 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 3 0 0 1 0 0 0 0 0
sentence 4: 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0
sentence 5: 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0
sentence 6: 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0
sentence 7: 0 1 1 0 0 0 0 0 0 0 0 2 0 0 1 0 1 0 0 1 0 2 0 0 0 0 1 0 0 0 0 0 0
sentence 8: 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
sentence 9: 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
sentence 10: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
sentence 11: 0 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0
sentence 12: 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 2 0 0 3 0 0 0 0 0
sentence 13: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
sentence 14: 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0
sentence 15: 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
sentence 16: 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 0 0 0 0 1 0 0 0 0 0 0
sentence 17: 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
sentence 18: 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
sentence 19: 0 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 2 0 1 0 1 0 1 0 0 0 0 0 0 0
sentence 20: 0 0 0 0 1 1 0 0 0 2 0 0 1 1 0 1 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 1
用4.4.4.4替换了所有IP地址。我希望它将4.4.4.4更新为现有的IP地址。
答案 0 :(得分:1)
您可以像这样在您的json中添加多个IP地址:
{
"Comment": "Update the A record set",
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "mydomain.com",
"Type": "A",
"TTL": 300,
"ResourceRecords": [{
"Value": "54.204.140.57"
},
{
"Value": "54.175.56.142"
}
]
}
}]
}
您可以像这样查询托管区域记录:
aws route53 list-resource-record-sets --hosted-zone-id {ZONEID} --query "ResourceRecordSets[?Type == 'A']"
这将返回json消息,例如:
[
{
"Name": "mydomain.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "54.204.140.57"
}
]
},
{
"Name": "mydomain.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "54.175.56.142"
}
]
}
]
答案 1 :(得分:0)
DNS更改需要一段时间来传播。
您对资源记录集的更改需要时间传播到Amazon Route 53 DNS服务器。目前,验证更改已传播的唯一方法是使用GetChange API操作。更改通常会在几分钟内传播到所有Amazon Route 53名称服务器。在极少数情况下,传播可能需要30分钟。
http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-editing.html
您可以在AWS route53 CLI中尝试更改
const fs = require('fs');
const path = require('path');
let output = {};
let lastDir = '';
const walk = (dir) => {
return new Promise((resolve, reject) => {
output[dir] = {
files: 0,
lines: 0,
path: ''
};
fs.readdir(dir, (err, list) => {
if (err) {
return reject(err);
}
let pending = list.length;
if (!pending) {
return resolve(output);
}
list.forEach((file) => {
file = path.resolve(dir, file);
fs.stat(file, (err, stat) => {
if (stat && stat.isDirectory()) {
walk(file)
.then((res) => {
if (!--pending) {
resolve(output);
}
})
}
else {
let lc = 0;
fs.createReadStream(file)
.on('data', (buffer) => {
buffer.forEach((chunk) => {
if (chunk === 10) {
lc++;
}
})
})
.on('end', () => {
output[dir].files++;
output[dir].lines += lc;
output[dir].path = dir;
if (!--pending) {
resolve(output);
}
});
}
})
})
})
});
};
walk('.')
.then(console.log)
.catch(console.log);
这将返回一个ID,您可以使用
查询状态Id - > (串) 请求的ID。
aws route53 change-resource-record-sets --hosted-zone-id <value> --change-batch <JSON doc>
这将返回更改的状态
状态 - &gt; (串) 请求的当前状态。 PENDING表示此请求尚未应用于所有Amazon Route 53 DNS服务器。
PENDING表示此请求中的更改未复制到所有Amazon Route 53 DNS服务器。这是所有更改批处理请求的初始状态。
INSYNC表示更改已复制到所有Amazon Route 53 DNS服务器。
http://docs.aws.amazon.com/cli/latest/reference/route53/get-change.html
http://docs.aws.amazon.com/cli/latest/reference/route53/change-resource-record-sets.html