Class: CfDeployer::Driver::Route53
- Inherits:
-
Object
- Object
- CfDeployer::Driver::Route53
- Defined in:
- lib/cf_deployer/driver/route53_driver.rb
Instance Method Summary collapse
- #delete_record_set(hosted_zone_name, target_host_name) ⇒ Object
- #find_alias_target(hosted_zone_name, target_host_name) ⇒ Object
-
#initialize(aws_route53 = nil) ⇒ Route53
constructor
A new instance of Route53.
- #set_alias_target(hosted_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
#delete_record_set(hosted_zone_name, target_host_name) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/cf_deployer/driver/route53_driver.rb', line 48 def delete_record_set(hosted_zone_name, target_host_name) hosted_zone = get_hosted_zone(hosted_zone_name) return unless hosted_zone record_set = get_record_set(hosted_zone, target_host_name) CfDeployer::Driver::DryRun.guard "Skipping Route53 DNS delete" do record_set.delete if record_set end end |
#find_alias_target(hosted_zone_name, target_host_name) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/cf_deployer/driver/route53_driver.rb', line 8 def find_alias_target(hosted_zone_name, target_host_name) hosted_zone = get_hosted_zone(hosted_zone_name) raise ApplicationError.new('Target zone not found!') if hosted_zone.nil? record_set = get_record_set(hosted_zone, target_host_name) return nil if record_set.nil? || record_set.alias_target.nil? remove_trailing_dot(record_set.alias_target[:dns_name]) end |
#set_alias_target(hosted_zone_name, target_host_name, elb_hosted_zone_id, elb_dnsname) ⇒ Object
16 17 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 |
# File 'lib/cf_deployer/driver/route53_driver.rb', line 16 def set_alias_target(hosted_zone_name, target_host_name, elb_hosted_zone_id, elb_dnsname) Log.info "set alias target --Hosted Zone: #{hosted_zone_name} --Host Name: #{target_host_name} --ELB DNS Name: #{elb_dnsname} --ELB Zone ID: #{elb_hosted_zone_id}" hosted_zone_name = trailing_dot(hosted_zone_name) target_host_name = trailing_dot(target_host_name) hosted_zone = @aws_route53.hosted_zones.find { |z| z.name == hosted_zone_name } raise ApplicationError.new('Target zone not found!') if hosted_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: hosted_zone.path, change_batch: { changes: [change] } } CfDeployer::Driver::DryRun.guard "Skipping Route53 DNS update" do change_resource_record_sets_with_retry(batch) end end |