Class: Roadworker::Route53Wrapper::HostedzoneWrapper

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/roadworker/route53-wrapper.rb

Overview

HostedzoneCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#log

Constructor Details

#initialize(hosted_zone, vpcs, options) ⇒ HostedzoneWrapper

Returns a new instance of HostedzoneWrapper.



80
81
82
83
84
# File 'lib/roadworker/route53-wrapper.rb', line 80

def initialize(hosted_zone, vpcs, options)
  @hosted_zone = hosted_zone
  @vpcs = vpcs
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (private)



132
133
134
# File 'lib/roadworker/route53-wrapper.rb', line 132

def method_missing(method_name, *args)
  @hosted_zone.send(method_name, *args)
end

Instance Attribute Details

#vpcsObject (readonly)

Returns the value of attribute vpcs.



86
87
88
# File 'lib/roadworker/route53-wrapper.rb', line 86

def vpcs
  @vpcs
end

Instance Method Details

#associate_vpc(vpc) ⇒ Object



110
111
112
113
114
115
116
117
118
# File 'lib/roadworker/route53-wrapper.rb', line 110

def associate_vpc(vpc)
  log(:info, "Associate #{vpc.inspect}", :green, @hosted_zone.name)
  unless @options.dry_run
    @options.route53.associate_vpc_with_hosted_zone(
      hosted_zone_id: @hosted_zone.id,
      vpc: vpc,
    )
  end
end

#deleteObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/roadworker/route53-wrapper.rb', line 93

def delete
  if @options.force
    log(:info, 'Delete Hostedzone', :red, @hosted_zone.name)

    self.rrsets.each do |record|
      record.delete
    end

    unless @options.dry_run
      @options.route53.delete_hosted_zone(id: @hosted_zone.id)
      @options.updated = true
    end
  else
    log(:info, 'Undefined Hostedzone (pass `--force` if you want to remove)', :yellow, @hosted_zone.name)
  end
end

#disassociate_vpc(vpc) ⇒ Object



120
121
122
123
124
125
126
127
128
# File 'lib/roadworker/route53-wrapper.rb', line 120

def disassociate_vpc(vpc)
  log(:info, "Disassociate #{vpc.inspect}", :red, @hosted_zone.name)
  unless @options.dry_run
    @options.route53.disassociate_vpc_from_hosted_zone(
      hosted_zone_id: @hosted_zone.id,
      vpc: vpc,
    )
  end
end

#resource_record_setsObject Also known as: rrsets



88
89
90
# File 'lib/roadworker/route53-wrapper.rb', line 88

def resource_record_sets
  ResourceRecordSetCollectionWrapper.new(@hosted_zone, @options)
end