Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 2 commits into from
Jan 16, 2018

Conversation

masterzen
Copy link
Contributor

This PR implements the Route53 version of the ALIAS record type.

Route53 ALIAS doesn't behave like a regular ALIAS, and is much more limited as its target can only be some specific AWS resources (ELB, S3 buckets, CloudFront distributions, etc...) 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:

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 API requires indicating the hosted zone id where the target is defined (those are listed in AWS documentation, see the R53_ALIAS documentation for links).
Theoretically it can be auto-discovered by looking at the target dns name in which the region and type of AWS resource can be inferred, and then lookup in a static map. Or we can use the AWS API to find the proper resource and get its hosted zone id, which unfortunately would require more permissions (and in this case the user would need to specify the resource id as target instead of the dns name which might not be very practical).
I thought it was kind of complicated so I resorted to the simple solution of letting the user indicate the zone id. The easy case is when referring to another record in the same zone, as we know already know the zone id, in which case it is not necessary to specify the zone id (that's the reason of the R53_ZONE modifier instead of a required parameters of the R53_ALIAS directive).

Note that unlike the regular ALIAS, the R53_ALIAS requires indicating the type of the resource, which can vary depending on the target. For a target pointing to another record in the same zone, it should be this record type, but for other it should either be a A or AAAA.

Please review, I'm fully open to suggestions and fixes.

@tlimoncelli
Copy link
Contributor

Wow! I'm so happy that you took the time to write R53_ALIAS! People have been asking for this for ages but we (stackoverflow) don't use AWS so we don't have the knowledge of how to implement it.

I've made a couple very small comments. Please also add this to the feature matrix (ontrol/build/generate/featureMatrix.g) (The need to add that was only recently documented 79983f3)

Thanks!

@tlimoncelli tlimoncelli changed the title Support for Route53 ALIAS record type (#239) ROUTE53: Support Route53's ALIAS record type (#239) Jan 15, 2018
@masterzen masterzen force-pushed the feature/route53-alias branch from dec6915 to 2736a2b Compare January 15, 2018 19:13
@masterzen
Copy link
Contributor Author

@tlimoncelli I've pushed a new version of the PR containing the featureMatrix.go changes (along with some documentation formatting fixes).

@tlimoncelli
Copy link
Contributor

I guess I should have merged them in the other order. :-(

Could you rebase, "go generate" and check it in?

Brice Figureau added 2 commits January 15, 2018 23:14
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>
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 StackExchange#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).
@masterzen masterzen force-pushed the feature/route53-alias branch from 2736a2b to ff4073d Compare January 15, 2018 22:17
@masterzen
Copy link
Contributor Author

@tlimoncelli

I don't think it was possible to merge both without a conflict as both PRs touched helpers.js (and thus static.go).

Anyway, I've just pushed a rebased version (including generation of static.go).

Thanks!

@tlimoncelli tlimoncelli merged commit 7b8d608 into StackExchange:master Jan 16, 2018
rblenkinsopp pushed a commit to rblenkinsopp/dnscontrol that referenced this pull request Aug 21, 2020
…ckExchange#301)

* Stable comparison of metadata (StackExchange#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 (StackExchange#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 StackExchange#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).
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants