Class: Roadworker::Batch::Create

Inherits:
Operation show all
Defined in:
lib/roadworker/batch.rb

Instance Attribute Summary

Attributes inherited from Operation

#dry_run, #health_checks, #hosted_zone, #logger, #rrset

Instance Method Summary collapse

Methods inherited from Operation

#cname_first?, #initialize, #inspect, #present_rrset, #sort_key, #to_s, #value_size

Methods included from Log

#log

Constructor Details

This class inherits a constructor from Roadworker::Batch::Operation

Instance Method Details

#changesObject



239
240
241
242
243
244
245
246
# File 'lib/roadworker/batch.rb', line 239

def changes
  [
    {
      action: 'CREATE',
      resource_record_set: desired_rrset.to_h,
    },
  ]
end

#desired_rrsetHash

Returns:

  • (Hash)


212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/roadworker/batch.rb', line 212

def desired_rrset
  return @new_rrset if defined? @new_rrset 
  @new_rrset = {
    name: rrset.name,
    type: rrset.type,
  }

  Route53Wrapper::RRSET_ATTRS.each do |attribute|
    value = rrset.send(attribute)
    next unless value

    case attribute
    when :dns_name
      attribute = :alias_target
      dns_name, dns_name_opts = value
      value = get_alias_target(dns_name, dns_name_opts)
    when :health_check
      attribute = :health_check_id
      value = get_health_check(value)
    end

    @new_rrset[attribute] = value
  end

  @new_rrset
end

#diff!Object



248
249
250
251
252
# File 'lib/roadworker/batch.rb', line 248

def diff!
  log(:info, 'Create ResourceRecordSet', :cyan) do
    "#{desired_rrset[:name]} #{desired_rrset[:type]}#{ desired_rrset[:set_identifier] && " (#{desired_rrset[:set_identifier]})" }"
  end
end