1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

ROUTE53: Support Route53's ALIAS record type (#239) (#301)

* Stable comparison of metadata (#239)

Iterating over a map in Go never produces twice the same ordering.
Thus when comparing two metadata map with more than one key, the
`differ` is always finding differences.

To properly compare records metadata, we need to iterate the maps
in a deterministic way.

Signed-off-by: Brice Figureau <brice@daysofwonder.com>

* Support for Route53 ALIAS record type (#239)

Route53 ALIAS doesn't behave like a regular ALIAS, and is much more
limited as its target can only be some specific AWS resources or
another record in the same zone.

According to #239, this change adds a new directive R53_ALIAS which
implements this specific alias. This record type can only be used
with the Route53 provider.

This directive usage looks like this:
```js
D("example.com", REGISTRAR, DnsProvider("ROUTE53"),
R53_ALIAS("foo1", "A", "bar") // record in same zone
R53_ALIAS("foo2", "A",
  "blahblah.elasticloadbalancing.us-west-1.amazonaws.com",
   R53_ZONE('Z368ELLRRE2KJ0')) // ELB in us-west-1

```

Unfortunately, Route53 requires indicating the hosted zone id
where the target is defined (those are listed in AWS documentation,
see the R53_ALIAS documentation for links).
This commit is contained in:
Brice Figureau
2018-01-16 11:53:12 +01:00
committed by Tom Limoncelli
parent 2fc55dfdc4
commit 7b8d608019
15 changed files with 455 additions and 104 deletions

View File

@@ -165,6 +165,38 @@ var AAAA = recordBuilder('AAAA');
// ALIAS(name,target, recordModifiers...)
var ALIAS = recordBuilder('ALIAS');
// R53_ALIAS(name, target, type, recordModifiers...)
var R53_ALIAS = recordBuilder('R53_ALIAS', {
args: [['name', _.isString], ['type', validateR53AliasType], ['target', _.isString]],
transform: function (record, args, modifiers) {
record.name = args.name;
record.target = args.target;
if (_.isObject(record.r53_alias)) {
record.r53_alias['type'] = args.type;
} else {
record.r53_alias = { 'type': args.type };
}
},
});
// R53_ZONE(zone_id)
function R53_ZONE(zone_id) {
return function (r) {
if (_.isObject(r.r53_alias)) {
r.r53_alias['zone_id'] = zone_id;
} else {
r.r53_alias = { 'zone_id': zone_id }
}
};
}
function validateR53AliasType(value) {
if (!_.isString(value)) {
return false;
}
return ['A', 'AAAA', 'CNAME', 'CAA', 'MX', 'TXT', 'PTR', 'SPF', 'SRV', 'NAPTR'].indexOf(value) != -1;
}
// CAA(name,tag,value, recordModifiers...)
var CAA = recordBuilder('CAA', {
// TODO(tlim): It should be an error if value is not 0 or 128.