Class: Roadworker::Route53Wrapper::ResourceRecordSetCollectionWrapper
- Inherits:
-
Object
- Object
- Roadworker::Route53Wrapper::ResourceRecordSetCollectionWrapper
- Includes:
- Log
- Defined in:
- lib/roadworker/route53-wrapper.rb
Overview
HostedzoneWrapper
Instance Method Summary collapse
- #create(name, type, expected_record) ⇒ Object
- #each ⇒ Object
-
#initialize(hosted_zone, options) ⇒ ResourceRecordSetCollectionWrapper
constructor
A new instance of ResourceRecordSetCollectionWrapper.
Methods included from Log
Constructor Details
#initialize(hosted_zone, options) ⇒ ResourceRecordSetCollectionWrapper
Returns a new instance of ResourceRecordSetCollectionWrapper.
140 141 142 143 |
# File 'lib/roadworker/route53-wrapper.rb', line 140 def initialize(hosted_zone, ) @hosted_zone = hosted_zone @options = end |
Instance Method Details
#create(name, type, expected_record) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/roadworker/route53-wrapper.rb', line 153 def create(name, type, expected_record) log(:info, 'Create ResourceRecordSet', :cyan) do log_id = [name, type].join(' ') rrset_setid = expected_record.set_identifier rrset_setid ? (log_id + " (#{rrset_setid})") : log_id end if @options.dry_run record = expected_record else resource_record_set_params = { name: name, type: type, } Route53Wrapper::RRSET_ATTRS.each do |attribute| value = expected_record.send(attribute) next unless value case attribute when :dns_name attribute = :alias_target dns_name, dns_name_opts = value value = Aws::Route53.dns_name_to_alias_target(dns_name, dns_name_opts, @hosted_zone.id, @hosted_zone.name || @options.hosted_zone_name) when :health_check attribute = :health_check_id value = @options.health_checks.find_or_create(value) end resource_record_set_params[attribute] = value end @options.route53.change_resource_record_sets( hosted_zone_id: @hosted_zone.id, change_batch: { changes: [ { action: 'CREATE', resource_record_set: resource_record_set_params, }, ], }, ) @options.updated = true end ResourceRecordSetWrapper.new(expected_record, @hosted_zone, @options) end |
#each ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/roadworker/route53-wrapper.rb', line 145 def each if @hosted_zone.id Collection.batch(@options.route53.list_resource_record_sets(hosted_zone_id: @hosted_zone.id), :resource_record_sets) do |record| yield(ResourceRecordSetWrapper.new(record, @hosted_zone, @options)) end end end |