mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
ROUTE53: Allow R53_ALIAS records to enable target health evaluation (#2649)
This commit is contained in:
@ -395,6 +395,9 @@ func makeR53alias(rec *models.RecordConfig, ttl uint32) string {
|
||||
if z, ok := rec.R53Alias["zone_id"]; ok {
|
||||
items = append(items, `R53_ZONE("`+z+`")`)
|
||||
}
|
||||
if e, ok := rec.R53Alias["evaluate_target_health"]; ok && e == "true" {
|
||||
items = append(items, "R53_EVALUATE_TARGET_HEALTH(true)")
|
||||
}
|
||||
if ttl != 0 {
|
||||
items = append(items, fmt.Sprintf("TTL(%d)", ttl))
|
||||
}
|
||||
|
@ -68,3 +68,69 @@ func TestR53Test_2ttl(t *testing.T) {
|
||||
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
||||
}
|
||||
}
|
||||
|
||||
func TestR53Test_3(t *testing.T) {
|
||||
rec := models.RecordConfig{
|
||||
Type: "R53_ALIAS",
|
||||
Name: "foo",
|
||||
NameFQDN: "foo.domain.tld",
|
||||
}
|
||||
rec.SetTarget("bar")
|
||||
rec.R53Alias = make(map[string]string)
|
||||
rec.R53Alias["type"] = "A"
|
||||
rec.R53Alias["evaluate_target_health"] = "true"
|
||||
w := `R53_ALIAS("foo", "A", "bar", R53_EVALUATE_TARGET_HEALTH(true))`
|
||||
if g := makeR53alias(&rec, 0); g != w {
|
||||
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
||||
}
|
||||
}
|
||||
|
||||
func TestR53Test_3ttl(t *testing.T) {
|
||||
rec := models.RecordConfig{
|
||||
Type: "R53_ALIAS",
|
||||
Name: "foo",
|
||||
NameFQDN: "foo.domain.tld",
|
||||
}
|
||||
rec.SetTarget("bar")
|
||||
rec.R53Alias = make(map[string]string)
|
||||
rec.R53Alias["type"] = "A"
|
||||
rec.R53Alias["evaluate_target_health"] = "true"
|
||||
w := `R53_ALIAS("foo", "A", "bar", R53_EVALUATE_TARGET_HEALTH(true), TTL(123))`
|
||||
if g := makeR53alias(&rec, 123); g != w {
|
||||
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
||||
}
|
||||
}
|
||||
|
||||
func TestR53Test_4(t *testing.T) {
|
||||
rec := models.RecordConfig{
|
||||
Type: "R53_ALIAS",
|
||||
Name: "foo",
|
||||
NameFQDN: "foo.domain.tld",
|
||||
}
|
||||
rec.SetTarget("bar")
|
||||
rec.R53Alias = make(map[string]string)
|
||||
rec.R53Alias["type"] = "A"
|
||||
rec.R53Alias["zone_id"] = "blarg"
|
||||
rec.R53Alias["evaluate_target_health"] = "true"
|
||||
w := `R53_ALIAS("foo", "A", "bar", R53_ZONE("blarg"), R53_EVALUATE_TARGET_HEALTH(true))`
|
||||
if g := makeR53alias(&rec, 0); g != w {
|
||||
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
||||
}
|
||||
}
|
||||
|
||||
func TestR53Test_4ttl(t *testing.T) {
|
||||
rec := models.RecordConfig{
|
||||
Type: "R53_ALIAS",
|
||||
Name: "foo",
|
||||
NameFQDN: "foo.domain.tld",
|
||||
}
|
||||
rec.SetTarget("bar")
|
||||
rec.R53Alias = make(map[string]string)
|
||||
rec.R53Alias["type"] = "A"
|
||||
rec.R53Alias["zone_id"] = "blarg"
|
||||
rec.R53Alias["evaluate_target_health"] = "true"
|
||||
w := `R53_ALIAS("foo", "A", "bar", R53_ZONE("blarg"), R53_EVALUATE_TARGET_HEALTH(true), TTL(123))`
|
||||
if g := makeR53alias(&rec, 123); g != w {
|
||||
t.Errorf("makeR53alias failure: got `%s` want `%s`", g, w)
|
||||
}
|
||||
}
|
||||
|
13
commands/types/dnscontrol.d.ts
vendored
13
commands/types/dnscontrol.d.ts
vendored
@ -2279,11 +2279,13 @@ declare const PURGE: DomainModifier;
|
||||
* * _S3 bucket_ (configured as website): specify the hosted zone ID for the region that you created the bucket in. You can find it in [the List of regions and hosted Zone IDs](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region)
|
||||
* * _Another Route 53 record_: you can either specify the correct zone id or do not specify anything and DNSControl will figure out the right zone id. (Note: Route53 alias can't reference a record in a different zone).
|
||||
*
|
||||
* Target health evaluation can be enabled with the [`R53_EVALUATE_TARGET_HEALTH`](../record/R53_EVALUATE_TARGET_HEALTH.md) record modifier.
|
||||
*
|
||||
* ```javascript
|
||||
* D("example.com", REG_MY_PROVIDER, DnsProvider("ROUTE53"),
|
||||
* R53_ALIAS("foo", "A", "bar"), // record in same zone
|
||||
* R53_ALIAS("foo", "A", "bar", R53_ZONE("Z35SXDOTRQ7X7K")), // record in same zone, zone specified
|
||||
* R53_ALIAS("foo", "A", "blahblah.elasticloadbalancing.us-west-1.amazonaws.com.", R53_ZONE("Z368ELLRRE2KJ0")), // a classic ELB in us-west-1
|
||||
* R53_ALIAS("foo", "A", "blahblah.elasticloadbalancing.us-west-1.amazonaws.com.", R53_ZONE("Z368ELLRRE2KJ0"), R53_EVALUATE_TARGET_HEALTH(true)), // a classic ELB in us-west-1 with target health evaluation enabled
|
||||
* R53_ALIAS("foo", "A", "blahblah.elasticbeanstalk.us-west-2.amazonaws.com.", R53_ZONE("Z38NKT9BP95V3O")), // an Elastic Beanstalk environment in us-west-2
|
||||
* R53_ALIAS("foo", "A", "blahblah-bucket.s3-website-us-west-1.amazonaws.com.", R53_ZONE("Z2F56UZL2M1ACD")), // a website S3 Bucket in us-west-1
|
||||
* );
|
||||
@ -2291,7 +2293,14 @@ declare const PURGE: DomainModifier;
|
||||
*
|
||||
* @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/amazon-route-53/r53_alias
|
||||
*/
|
||||
declare function R53_ALIAS(name: string, target: string, zone_idModifier: DomainModifier & RecordModifier): DomainModifier;
|
||||
declare function R53_ALIAS(name: string, target: string, zone_idModifier: DomainModifier & RecordModifier, evaluatetargethealthModifier: RecordModifier): DomainModifier;
|
||||
|
||||
/**
|
||||
* `R53_EVALUATE_TARGET_HEALTH` lets you enable target health evaluation for a [`R53_ALIAS()`](../domain/R53_ALIAS.md) record. Omitting `R53_EVALUATE_TARGET_HEALTH()` from `R53_ALIAS()` set the behavior to false.
|
||||
*
|
||||
* @see https://docs.dnscontrol.org/language-reference/record-modifiers/service-provider-specific/amazon-route-53/r53_evaluate_target_health
|
||||
*/
|
||||
declare function R53_EVALUATE_TARGET_HEALTH(enabled: bool): RecordModifier;
|
||||
|
||||
/**
|
||||
* `R53_ZONE` lets you specify the AWS Zone ID for an entire domain ([`D()`](../global/D.md)) or a specific [`R53_ALIAS()`](../domain/R53_ALIAS.md) record.
|
||||
|
Reference in New Issue
Block a user