class Route53Aliaser::Route53Updater
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
# File lib/route53_aliaser/route53_updater.rb, line 6 def initialize(config) @config = config end
Public Instance Methods
update_target(target_record, source_record, ips, zone_id)
click to toggle source
# File lib/route53_aliaser/route53_updater.rb, line 10 def update_target(target_record, source_record, ips, zone_id) a_record = { action: "UPSERT", resource_record_set: { name: target_record, type: "A", ttl: 60, resource_records: ips.collect{ |ip| { value: ip } } } } txt_record = { action: "UPSERT", resource_record_set: { name: target_record, type: "TXT", ttl: 60, resource_records: [value: %{"ALIAS for #{source_record}"}] } } change_batch = { comment: "auto updated", changes: [a_record, txt_record] } options = { hosted_zone_id: zone_id, change_batch: change_batch } rt53 = get_configured_aws_client res = rt53.client.change_resource_record_sets(options) res && res.successful? end
Private Instance Methods
get_configured_aws_client()
click to toggle source
# File lib/route53_aliaser/route53_updater.rb, line 46 def get_configured_aws_client if(config.aws_access_key_id && config.aws_secret_access_key) AWS::Route53.new(access_key_id: config.aws_access_key_id, secret_access_key: config.aws_secret_access_key) else # Use the config set at the AWS module level (probably set for something else) AWS::Route53.new end end