route53_aliaser 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +16 -7
- data/app/controllers/route53_aliaser/aliaser_controller.rb +3 -0
- data/lib/route53_aliaser/aliaser.rb +1 -1
- data/lib/route53_aliaser/route53_updater.rb +12 -3
- data/lib/route53_aliaser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55a19d25db468ae49a78b2ae10f421630832f544
|
4
|
+
data.tar.gz: ce8bccc80160b3db178e7cf1b254fb72c998d33a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baa2263d6ca60e1e1416d8505db74553076150765d1b236b260eaf0a1e673d0af58de965ad7803663bdf8dfa7c0b37e8026c7fb0bc577dd00ef59e4e8abc27e3
|
7
|
+
data.tar.gz: 9388b2047a7c99ccf23dd0317f8ecc5aad60881110f62a6387411cb879901fb463dea83262ff890c35b97dc4554d6ebdc5a393f64a0846469f6cabd1af9bed77
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Route53Aliaser 0.0.4
|
2
|
+
- Add TXT record alongside A-Record indicating that this is an ALIAS (#4)
|
3
|
+
- Raise error if the Rails Engine is called with a `request.host` that matches
|
4
|
+
the `target_record`. This avoids a chicken-and-egg problem.
|
5
|
+
|
1
6
|
# Route53Aliaser 0.0.3
|
2
7
|
- increase log verbosity on NOOP and Matches (helps to provide assurance that
|
3
8
|
we're doing *something*)
|
data/README.md
CHANGED
@@ -69,15 +69,21 @@ Next, mount the Rails Engine at a URL of your choosing:
|
|
69
69
|
# ./config/routes.rb
|
70
70
|
mount Route53Aliaser::Engine => '/route53-update'
|
71
71
|
|
72
|
-
Finally, set up something to
|
72
|
+
Finally, set up something to request this URL occasionally:
|
73
73
|
|
74
|
-
$ curl https://example.com/route53-update
|
74
|
+
$ curl https://www.example.com/route53-update
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
NOTE: This MUST be your CNAME, not the root! (for obvious reasons)
|
77
|
+
|
78
|
+
The easiest way to do this is to monitor that URL via a free service like
|
79
|
+
[Pingdom](http://www.pingdom.com/free) or [NewRelic](http://www.newrelic.com).
|
80
|
+
Since the DNS lookups are cached, most of the time requests to this URL will
|
81
|
+
return nearly instantly. Pingdom defaults to checking once per minute, which
|
82
|
+
should be within even the shortest TTLs. It appears that NewRelic checks
|
83
|
+
approximately once every [20
|
84
|
+
seconds](https://docs.newrelic.com/docs/alerts/alert-policies/downtime-alerts/availability-monitoring),
|
85
|
+
which is probably overkill but shouldn't really matter since we don't do
|
86
|
+
anything if the cache is fresh.
|
81
87
|
|
82
88
|
Heroku's [free scheduler](https://devcenter.heroku.com/articles/scheduler) has
|
83
89
|
an "every 10 minutes" option that could also be used for this. Just put the
|
@@ -88,6 +94,9 @@ the "once an hour" option instead. The downside to this approach is that the
|
|
88
94
|
further you stretch out the update interval the more likely you are to end up
|
89
95
|
with an out of date A-Record.
|
90
96
|
|
97
|
+
Whatever you choose, be sure the URL you are pinging is the CNAME and *not*
|
98
|
+
your root domain! (Otherwise, how could this possibly work?)
|
99
|
+
|
91
100
|
#### Without Rails
|
92
101
|
|
93
102
|
If you're not using Rails, or if you'd like to update ad-hoc, just call
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Route53Aliaser
|
2
2
|
class AliaserController < ActionController::Base
|
3
3
|
def update
|
4
|
+
if request.host == Route53Aliaser.config.target_record
|
5
|
+
raise "Route53Updater: Update requested on URL of target_zone. Please make request via source_zone."
|
6
|
+
end
|
4
7
|
Route53Aliaser.update_alias_if_needed
|
5
8
|
head :ok
|
6
9
|
end
|
@@ -25,7 +25,7 @@ module Route53Aliaser
|
|
25
25
|
else
|
26
26
|
config.logger.info "Route53Aliaser: IPs for #{config.target_record} #{target_ips} differ from #{config.source_record} #{source_ips}; will attempt to update"
|
27
27
|
rt53 = Route53Updater.new(config)
|
28
|
-
rt53.update_target(config.target_record, source_ips, config.zone_id)
|
28
|
+
rt53.update_target(config.target_record, config.source_record, source_ips, config.zone_id)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -7,8 +7,8 @@ module Route53Aliaser
|
|
7
7
|
@config = config
|
8
8
|
end
|
9
9
|
|
10
|
-
def update_target(target_record, ips, zone_id)
|
11
|
-
|
10
|
+
def update_target(target_record, source_record, ips, zone_id)
|
11
|
+
a_record = {
|
12
12
|
action: "UPSERT",
|
13
13
|
resource_record_set: {
|
14
14
|
name: target_record,
|
@@ -17,9 +17,18 @@ module Route53Aliaser
|
|
17
17
|
resource_records: ips.collect{ |ip| { value: ip } }
|
18
18
|
}
|
19
19
|
}
|
20
|
+
txt_record = {
|
21
|
+
action: "UPSERT",
|
22
|
+
resource_record_set: {
|
23
|
+
name: target_record,
|
24
|
+
type: "TXT",
|
25
|
+
ttl: 60,
|
26
|
+
resource_records: [value: %{"ALIAS for #{source_record}"}]
|
27
|
+
}
|
28
|
+
}
|
20
29
|
change_batch = {
|
21
30
|
comment: "auto updated",
|
22
|
-
changes: [
|
31
|
+
changes: [a_record, txt_record]
|
23
32
|
}
|
24
33
|
options = {
|
25
34
|
hosted_zone_id: zone_id,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: route53_aliaser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Dlugosz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|