Class: CfDeployer::Driver::Route53
- Inherits:
-
Object
- Object
- CfDeployer::Driver::Route53
- Defined in:
- lib/cf_deployer/driver/route53_driver.rb
Instance Method Summary collapse
- #find_alias_target(target_zone_name, target_host_name) ⇒ Object
-
#initialize(aws_route53 = nil) ⇒ Route53
constructor
A new instance of Route53.
- #set_alias_target(target_zone_name, target_host_name, elb_hosted_zone_id, elb_dnsname) ⇒ Object
Constructor Details
#initialize(aws_route53 = nil) ⇒ Route53
Returns a new instance of Route53.
4 5 6 |
# File 'lib/cf_deployer/driver/route53_driver.rb', line 4 def initialize(aws_route53 = nil) @aws_route53 = aws_route53 || AWS::Route53.new end |
Instance Method Details
#find_alias_target(target_zone_name, target_host_name) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/cf_deployer/driver/route53_driver.rb', line 8 def find_alias_target(target_zone_name, target_host_name) target_zone = @aws_route53.hosted_zones.find { |z| z.name == trailing_dot(target_zone_name.downcase) } raise ApplicationError.new('Target zone not found!') if target_zone.nil? target_host = target_zone.resource_record_sets.find { |r| r.name == trailing_dot(target_host_name.downcase) } return nil if target_host.nil? || target_host.alias_target.nil? remove_trailing_dot(target_host.alias_target[:dns_name]) end |
#set_alias_target(target_zone_name, target_host_name, elb_hosted_zone_id, elb_dnsname) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cf_deployer/driver/route53_driver.rb', line 18 def set_alias_target(target_zone_name, target_host_name, elb_hosted_zone_id, elb_dnsname) Log.info "set alias target --Hosted Zone: #{target_zone_name} --Host Name: #{target_host_name} --ELB DNS Name: #{elb_dnsname} --ELB Zone ID: #{elb_hosted_zone_id}" target_zone_name = trailing_dot(target_zone_name) target_host_name = trailing_dot(target_host_name) target_zone = @aws_route53.hosted_zones.find { |z| z.name == target_zone_name } raise ApplicationError.new('Target zone not found!') if target_zone.nil? change = { action: "UPSERT", resource_record_set: { name: target_host_name, type: "A", alias_target: { dns_name: elb_dnsname, hosted_zone_id: elb_hosted_zone_id, evaluate_target_health: false } } } batch = { hosted_zone_id: target_zone.path, change_batch: { changes: [change] } } CfDeployer::Driver::DryRun.guard "Skipping Route53 DNS update" do change_resource_record_sets_with_retry(batch) end end |