class Dynamic53
Constants
- DEFAULT_TTL
- VERSION
Attributes
hostname[R]
options[R]
zone[R]
Public Class Methods
new(zone, hostname, options={})
click to toggle source
Initializes an object for updating the Route 53 hostname with the machine's current public IP address.
# File lib/dynamic_53.rb, line 15 def initialize(zone, hostname, options={}) @zone = zone @hostname = hostname @options = options end
Public Instance Methods
ip_address()
click to toggle source
fetch the current machine's public IP address.
# File lib/dynamic_53.rb, line 31 def ip_address @ip_address ||= begin ip_address = Net::HTTP.get("bot.whatismyipaddress.com", "/") $stdout.puts "Public IP Address: #{ip_address}" if options[:verbose] ip_address end end
record_set()
click to toggle source
Fetch a record set object for the given hostname in the Route 53 zone specified.
# File lib/dynamic_53.rb, line 51 def record_set @record_set ||= AWS::Route53::HostedZone.new(zone_id).rrsets[hostname, 'A'] end
route_53_client()
click to toggle source
A client for making Route 53 API requests.
# File lib/dynamic_53.rb, line 56 def route_53_client @route_53_client ||= AWS::Route53.new.client end
update()
click to toggle source
perform the Route 53 update, returning the AWS SDK changelist object for the change.
# File lib/dynamic_53.rb, line 22 def update record_set.ttl = options[:ttl] || DEFAULT_TTL record_set.resource_records = [{:value => ip_address}] result = record_set.update $stdout.puts "Record updated" if options[:verbose] result end
zone_id()
click to toggle source
Fetches the AWS Route53 zone id for the specified zone.
# File lib/dynamic_53.rb, line 41 def zone_id route_53_client. list_hosted_zones[:hosted_zones]. each. select { |z| z[:name] == zone }. map {|z| z[:id] }. first end