class ApartmentAcmeClient::DnsApi::Route53
Attributes
label[R]
the DNS TXT record label (full label, including domain)
record_type[R]
will be TXT
requested_domain[R]
The domain being requested for DNS update e.g. “site.example.com”
values[R]
array of value keys to be written (for wildcard certs, you'll have one for *.example.com, and one for example.com) e.g. [“One”, “Two”]
Public Class Methods
new(requested_domain:, dns_record_label:, record_type:, values:)
click to toggle source
# File lib/apartment_acme_client/dns_api/route53.rb, line 22 def initialize(requested_domain:, dns_record_label:, record_type:, values:) @requested_domain = requested_domain @label = dns_record_label @record_type = record_type @values = values end
Public Instance Methods
write_record()
click to toggle source
NOTE: if you get error like:
“Invalid Resource Record: FATAL problem: InvalidCharacterString (Value should be enclosed in quotation marks) encountered with <value>”
this means that the “Value” should include escape quotes. e.g. values: [“"Something"”, “"Other Thing"”]
# File lib/apartment_acme_client/dns_api/route53.rb, line 38 def write_record route53.change_resource_record_sets(options) end
Private Instance Methods
options()
click to toggle source
# File lib/apartment_acme_client/dns_api/route53.rb, line 44 def options change = { action: 'UPSERT', resource_record_set: { name: label, type: record_type, ttl: 1, resource_records: resource_record_values } } { hosted_zone_id: zone.id, change_batch: { changes: [change] } } end
resource_record_values()
click to toggle source
createt an AwsRoute53 upsert with multiple value entries
# File lib/apartment_acme_client/dns_api/route53.rb, line 79 def resource_record_values values.map do |value| if value.include?("\"") { value: value } else { value: "\"#{value}\"" } end end end
root_domain()
click to toggle source
# File lib/apartment_acme_client/dns_api/route53.rb, line 63 def root_domain requested_domain.split(".").last(2).join(".") end
route53()
click to toggle source
# File lib/apartment_acme_client/dns_api/route53.rb, line 73 def route53 # Note: The `region` doesn't matter, because Route53 is global. @route53 ||= Aws::Route53::Client.new(region: 'us-east-1') end
zone()
click to toggle source
# File lib/apartment_acme_client/dns_api/route53.rb, line 67 def zone @zone = route53.list_hosted_zones(max_items: 100) .hosted_zones .detect { |z| z.name = "#{root_domain}." } end