ConradIrwin/aws-name-server — pull request #4 by bremac (2014-11-10 04:28:59+00:00)
Title: Add support for wildcard subdomains

My company has several staging and demo instances that we would like to resolve with aws-name-server. Every instance has a number of nginx virtualhosts corresponding to different services running on it; for example, we'd like foo.demo-5.ec2.elacarte.com and bar.demo-5.ec2.elacarte.com to both resolve to demo-5.ec2.elacarte.com. Unfortunately, aws-name-server doesn't seem to support this out of the box.

To get this functionality, this pull request adds a flag that causes `*..` to always resolve to `.`. This is somewhat intrusive, but is fairly consistent -- any subdomain of `.` will resolve to `.`. A less intrusive but less consistent alternative would be to resolve all non-numeric subdomains to the instance name as in the diff below.

Note that I haven't updated the documentation yet -- I'd like to get feedback on what approach you prefer, even though both approaches are only minor changes.

```diff
diff --git a/ec2_server.go b/ec2_server.go
index f02e48a..f1a64d0 100644
--- a/ec2_server.go
+++ b/ec2_server.go
@@ -132,8 +132,8 @@ func (s *EC2Server) Lookup(msg dns.Question) []*Record {
if len(parts) > 1 {
if i, err := strconv.Atoi(parts[0]); err == nil && i > 0 {
nth = i
- parts = parts[1:]
}
+ parts = parts[1:]
}

if len(parts) != 1 || parts[0] == "" {
```