mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-09-20 06:46:19 +08:00
ROUTE53: Allow R53_ALIAS records to enable target health evaluation (#2649)
This commit is contained in:
parent
bf9e48d06f
commit
e783d7024c
|
@ -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.
|
||||
|
|
|
@ -4,10 +4,12 @@ parameters:
|
|||
- name
|
||||
- target
|
||||
- ZONE_ID modifier
|
||||
- EvaluateTargetHealth modifier
|
||||
parameter_types:
|
||||
name: string
|
||||
target: string
|
||||
ZONE_ID modifier: DomainModifier & RecordModifier
|
||||
EvaluateTargetHealth modifier: RecordModifier
|
||||
provider: ROUTE53
|
||||
---
|
||||
|
||||
|
@ -37,12 +39,14 @@ The zone id can be found depending on the target type:
|
|||
* _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.
|
||||
|
||||
{% code title="dnsconfig.js" %}
|
||||
```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
|
||||
);
|
||||
|
|
11
documentation/functions/record/R53_EVALUATE_TARGET_HEALTH.md
Normal file
11
documentation/functions/record/R53_EVALUATE_TARGET_HEALTH.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
name: R53_EVALUATE_TARGET_HEALTH
|
||||
parameters:
|
||||
- enabled
|
||||
parameter_types:
|
||||
enabled: bool
|
||||
ts_return: RecordModifier
|
||||
provider: ROUTE53
|
||||
---
|
||||
|
||||
`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.
|
|
@ -597,10 +597,11 @@ func ptr(name, target string) *models.RecordConfig {
|
|||
return makeRec(name, target, "PTR")
|
||||
}
|
||||
|
||||
func r53alias(name, aliasType, target string) *models.RecordConfig {
|
||||
func r53alias(name, aliasType, target, evalTargetHealth string) *models.RecordConfig {
|
||||
r := makeRec(name, target, "R53_ALIAS")
|
||||
r.R53Alias = map[string]string{
|
||||
"type": aliasType,
|
||||
"type": aliasType,
|
||||
"evaluate_target_health": evalTargetHealth,
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
@ -1581,12 +1582,12 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
tc("ALIAS to A record in same zone",
|
||||
a("kyle", "1.2.3.4"),
|
||||
a("cartman", "2.3.4.5"),
|
||||
r53alias("kenny", "A", "kyle.**current-domain**"),
|
||||
r53alias("kenny", "A", "kyle.**current-domain**", "false"),
|
||||
),
|
||||
tc("modify an r53 alias",
|
||||
a("kyle", "1.2.3.4"),
|
||||
a("cartman", "2.3.4.5"),
|
||||
r53alias("kenny", "A", "cartman.**current-domain**"),
|
||||
r53alias("kenny", "A", "cartman.**current-domain**", "false"),
|
||||
),
|
||||
),
|
||||
|
||||
|
@ -1599,12 +1600,12 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
tc("add an alias to 18",
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
cname("dev-system19", "ec2-54-91-99-999.compute-1.amazonaws.com."),
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**"),
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**", "false"),
|
||||
),
|
||||
tc("modify alias to 19",
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
cname("dev-system19", "ec2-54-91-99-999.compute-1.amazonaws.com."),
|
||||
r53alias("dev-system", "CNAME", "dev-system19.**current-domain**"),
|
||||
r53alias("dev-system", "CNAME", "dev-system19.**current-domain**", "false"),
|
||||
),
|
||||
tc("remove alias",
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
|
@ -1613,17 +1614,17 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
tc("add an alias back",
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
cname("dev-system19", "ec2-54-91-99-999.compute-1.amazonaws.com."),
|
||||
r53alias("dev-system", "CNAME", "dev-system19.**current-domain**"),
|
||||
r53alias("dev-system", "CNAME", "dev-system19.**current-domain**", "false"),
|
||||
),
|
||||
tc("remove cnames",
|
||||
r53alias("dev-system", "CNAME", "dev-system19.**current-domain**"),
|
||||
r53alias("dev-system", "CNAME", "dev-system19.**current-domain**", "false"),
|
||||
),
|
||||
),
|
||||
|
||||
testgroup("R53_ALIAS_CNAME",
|
||||
requires(providers.CanUseRoute53Alias),
|
||||
tc("create alias+cname in one step",
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**"),
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**", "false"),
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
),
|
||||
|
@ -1634,7 +1635,7 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
// See https://github.com/StackExchange/dnscontrol/issues/2107
|
||||
requires(providers.CanUseRoute53Alias),
|
||||
tc("loop should fail",
|
||||
r53alias("test-islandora", "CNAME", "test-islandora.**current-domain**"),
|
||||
r53alias("test-islandora", "CNAME", "test-islandora.**current-domain**", "false"),
|
||||
),
|
||||
),
|
||||
|
||||
|
@ -1642,7 +1643,7 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
testgroup("R53_alias pre-existing",
|
||||
requires(providers.CanUseRoute53Alias),
|
||||
tc("Create some records",
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**"),
|
||||
r53alias("dev-system", "CNAME", "dev-system18.**current-domain**", "false"),
|
||||
cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
tc("Add a new record - ignoring foo",
|
||||
|
@ -1651,6 +1652,18 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
),
|
||||
),
|
||||
|
||||
testgroup("R53_alias evaluate_target_health",
|
||||
requires(providers.CanUseRoute53Alias),
|
||||
tc("Create alias and cname",
|
||||
r53alias("test-record", "CNAME", "test-record-1.**current-domain**", "false"),
|
||||
cname("test-record-1", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
tc("modify evaluate target health",
|
||||
r53alias("test-record", "CNAME", "test-record-1.**current-domain**", "true"),
|
||||
cname("test-record-1", "ec2-54-91-33-155.compute-1.amazonaws.com."),
|
||||
),
|
||||
),
|
||||
|
||||
// CLOUDFLAREAPI features
|
||||
|
||||
testgroup("CF_REDIRECT",
|
||||
|
|
|
@ -49,7 +49,7 @@ func (rc *RecordConfig) GetTargetCombined() string {
|
|||
switch rc.Type { // #rtype_variations
|
||||
case "R53_ALIAS":
|
||||
// Differentiate between multiple R53_ALIASs on the same label.
|
||||
return fmt.Sprintf("%s atype=%s zone_id=%s", rc.target, rc.R53Alias["type"], rc.R53Alias["zone_id"])
|
||||
return fmt.Sprintf("%s atype=%s zone_id=%s evaluate_target_health=%s", rc.target, rc.R53Alias["type"], rc.R53Alias["zone_id"], rc.R53Alias["evaluate_target_health"])
|
||||
case "AZURE_ALIAS":
|
||||
// Differentiate between multiple AZURE_ALIASs on the same label.
|
||||
return fmt.Sprintf("%s atype=%s", rc.target, rc.AzureAlias["type"])
|
||||
|
@ -115,7 +115,7 @@ func (rc *RecordConfig) GetTargetDebug() string {
|
|||
case "NAPTR":
|
||||
content += fmt.Sprintf(" naptrorder=%d naptrpreference=%d naptrflags=%s naptrservice=%s naptrregexp=%s", rc.NaptrOrder, rc.NaptrPreference, rc.NaptrFlags, rc.NaptrService, rc.NaptrRegexp)
|
||||
case "R53_ALIAS":
|
||||
content += fmt.Sprintf(" type=%s zone_id=%s", rc.R53Alias["type"], rc.R53Alias["zone_id"])
|
||||
content += fmt.Sprintf(" type=%s zone_id=%s evaluate_target_health=%s", rc.R53Alias["type"], rc.R53Alias["zone_id"], rc.R53Alias["evaluate_target_health"])
|
||||
case "SOA":
|
||||
content = fmt.Sprintf("%s ns=%v mbox=%v serial=%v refresh=%v retry=%v expire=%v minttl=%v", rc.Type, rc.target, rc.SoaMbox, rc.SoaSerial, rc.SoaRefresh, rc.SoaRetry, rc.SoaExpire, rc.SoaMinttl)
|
||||
case "SRV":
|
||||
|
|
|
@ -328,8 +328,14 @@ var R53_ALIAS = recordBuilder('R53_ALIAS', {
|
|||
record.target = args.target;
|
||||
if (_.isObject(record.r53_alias)) {
|
||||
record.r53_alias['type'] = args.type;
|
||||
if (!_.isString(record.r53_alias['evaluate_target_health'])) {
|
||||
record.r53_alias['evaluate_target_health'] = 'false';
|
||||
}
|
||||
} else {
|
||||
record.r53_alias = { type: args.type };
|
||||
record.r53_alias = {
|
||||
type: args.type,
|
||||
evaluate_target_health: 'false',
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -347,6 +353,17 @@ function R53_ZONE(zone_id) {
|
|||
};
|
||||
}
|
||||
|
||||
// R53_EVALUATE_TARGET_HEALTH(enabled)
|
||||
function R53_EVALUATE_TARGET_HEALTH(enabled) {
|
||||
return function (r) {
|
||||
if (_.isObject(r.r53_alias)) {
|
||||
r.r53_alias['evaluate_target_health'] = enabled.toString();
|
||||
} else {
|
||||
r.r53_alias = { evaluate_target_health: enabled.toString() };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function validateR53AliasType(value) {
|
||||
if (!_.isString(value)) {
|
||||
return false;
|
||||
|
|
|
@ -2,6 +2,7 @@ D("foo.com", "none",
|
|||
R53_ALIAS("mxtest", "MX", "foo.com."),
|
||||
R53_ALIAS("atest", "A", "foo.com."),
|
||||
R53_ALIAS("atest", "A", "foo.com.", R53_ZONE("Z2FTEDLFRTF")),
|
||||
R53_ALIAS("aevaltargethealthtest", "A", "foo.com.", R53_EVALUATE_TARGET_HEALTH(true)),
|
||||
R53_ALIAS("aaaatest", "AAAA", "foo.com."),
|
||||
R53_ALIAS("aaaatest", "AAAA", "foo.com.", R53_ZONE("ERERTFGFGF")),
|
||||
R53_ALIAS("cnametest", "CNAME", "foo.com."),
|
||||
|
|
|
@ -12,15 +12,8 @@
|
|||
"name": "mxtest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "MX"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "R53_ALIAS",
|
||||
"name": "atest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "A"
|
||||
"type": "MX",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -29,15 +22,26 @@
|
|||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "A",
|
||||
"zone_id": "Z2FTEDLFRTF"
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "R53_ALIAS",
|
||||
"name": "aaaatest",
|
||||
"name": "atest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "AAAA"
|
||||
"type": "A",
|
||||
"zone_id": "Z2FTEDLFRTF",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "R53_ALIAS",
|
||||
"name": "aevaltargethealthtest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "A",
|
||||
"evaluate_target_health": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -46,7 +50,17 @@
|
|||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "AAAA",
|
||||
"zone_id": "ERERTFGFGF"
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "R53_ALIAS",
|
||||
"name": "aaaatest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "AAAA",
|
||||
"zone_id": "ERERTFGFGF",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +68,8 @@
|
|||
"name": "cnametest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "CNAME"
|
||||
"type": "CNAME",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -62,7 +77,8 @@
|
|||
"name": "ptrtest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "PTR"
|
||||
"type": "PTR",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -70,7 +86,8 @@
|
|||
"name": "txttest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "TXT"
|
||||
"type": "TXT",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -78,7 +95,8 @@
|
|||
"name": "srvtest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "SRV"
|
||||
"type": "SRV",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -86,7 +104,8 @@
|
|||
"name": "spftest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "SPF"
|
||||
"type": "SPF",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -94,7 +113,8 @@
|
|||
"name": "caatest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "CAA"
|
||||
"type": "CAA",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -102,7 +122,8 @@
|
|||
"name": "naptrtest",
|
||||
"target": "foo.com.",
|
||||
"r53_alias": {
|
||||
"type": "NAPTR"
|
||||
"type": "NAPTR",
|
||||
"evaluate_target_health": "false"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
"name": "atest",
|
||||
"r53_alias": {
|
||||
"type": "A",
|
||||
"zone_id": "Z2FTEDLFRTZ"
|
||||
"zone_id": "Z2FTEDLFRTZ",
|
||||
"evaluate_target_health": "false"
|
||||
},
|
||||
"target": "foo.com."
|
||||
}
|
||||
|
|
|
@ -323,10 +323,10 @@ func TestWriteZoneFileSynth(t *testing.T) {
|
|||
; c4
|
||||
@ IN A 192.30.252.153
|
||||
IN A 192.30.252.154
|
||||
;myalias IN R53_ALIAS atype= zone_id=
|
||||
;myalias IN R53_ALIAS atype= zone_id=
|
||||
;myalias IN R53_ALIAS atype= zone_id= evaluate_target_health=
|
||||
;myalias IN R53_ALIAS atype= zone_id= evaluate_target_health=
|
||||
www IN CNAME bosun.org.
|
||||
;zalias IN R53_ALIAS atype= zone_id=
|
||||
;zalias IN R53_ALIAS atype= zone_id= evaluate_target_health=
|
||||
`
|
||||
if buf.String() != expected {
|
||||
t.Log(buf.String())
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
@ -435,8 +436,9 @@ func nativeToRecords(set r53Types.ResourceRecordSet, origin string) ([]*models.R
|
|||
Type: "R53_ALIAS",
|
||||
TTL: 300,
|
||||
R53Alias: map[string]string{
|
||||
"type": string(set.Type),
|
||||
"zone_id": aws.ToString(set.AliasTarget.HostedZoneId),
|
||||
"type": string(set.Type),
|
||||
"zone_id": aws.ToString(set.AliasTarget.HostedZoneId),
|
||||
"evaluate_target_health": strconv.FormatBool(set.AliasTarget.EvaluateTargetHealth),
|
||||
},
|
||||
}
|
||||
rc.SetLabelFromFQDN(unescape(set.Name), origin)
|
||||
|
@ -510,12 +512,16 @@ func nativeToRecords(set r53Types.ResourceRecordSet, origin string) ([]*models.R
|
|||
func aliasToRRSet(zone r53Types.HostedZone, r *models.RecordConfig) *r53Types.ResourceRecordSet {
|
||||
target := r.GetTargetField()
|
||||
zoneID := getZoneID(zone, r)
|
||||
evalTargetHealth, err := strconv.ParseBool(r.R53Alias["evaluate_target_health"])
|
||||
if err != nil {
|
||||
evalTargetHealth = false
|
||||
}
|
||||
rrset := &r53Types.ResourceRecordSet{
|
||||
Type: r53Types.RRType(r.R53Alias["type"]),
|
||||
AliasTarget: &r53Types.AliasTarget{
|
||||
DNSName: &target,
|
||||
HostedZoneId: aws.String(zoneID),
|
||||
EvaluateTargetHealth: false,
|
||||
EvaluateTargetHealth: evalTargetHealth,
|
||||
},
|
||||
}
|
||||
return rrset
|
||||
|
|
Loading…
Reference in a new issue