class Arec53::CLI

Constants

DEFAULT_REGION

Public Instance Methods

update(hosted_zone_id, record_set_name, ip_address = my_ip, ttl = 300) click to toggle source
# File lib/arec53/cli.rb, line 19
def update hosted_zone_id, record_set_name, ip_address = my_ip, ttl = 300
  begin
    response = client.change_resource_record_sets(
      hosted_zone_id: hosted_zone_id,

      change_batch: {
        changes: [
          {
            action: "UPSERT",

            resource_record_set: {
              name: record_set_name,
              type: "A",
              ttl:  ttl,

              resource_records: [
                {
                  value: ip_address,
                },
              ],
            },
          },
        ],
      },
    )

    fail unless response.successful?
    puts "Success"
  rescue => ex
    puts "Failed?"
    p ex
    puts ex.backtrace
  end
end
version() click to toggle source
# File lib/arec53/cli.rb, line 14
def version
  puts Arec53::VERSION
end

Private Instance Methods

client() click to toggle source
# File lib/arec53/cli.rb, line 60
def client
  @client ||= Aws::Route53::Client.new region: (options[:region] || DEFAULT_REGION)
end
my_ip() click to toggle source
# File lib/arec53/cli.rb, line 56
def my_ip
  Net::HTTP.get("checkip.amazonaws.com", "/").chomp
end