Skip to content
Permalink
Browse files

Delete hosted zone and its records correctly

When I tried to delete hosted zone, I got the following error.

```
$ roadwork -a --dry-run --target '^foo.bar$' --force
Apply `Routefile` to Route53 (dry-run)
Delete Hostedzone: foo.bar. (dry-run)
[ERROR] NoMethodError: undefined method `delete' for #<Aws::Route53::Types::ResourceRecordSet:0x00007ff81a9a3278>
```

ResourceRecordSetWrapper#delete was removed in a3876f6#diff-f8d164d49d5178a7c052045f1e269148.

So I changed to submit a batch request to delete records associated with
the target hosted zone as well.
  • Loading branch information
itkq committed Dec 27, 2019
1 parent 03599f6 commit bacf761f048588e0042b3a4c5b601cca3e03a05a
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/roadworker/route53-wrapper.rb
@@ -99,10 +99,13 @@ def delete
if @options.force
log(:info, 'Delete Hostedzone', :red, @hosted_zone.name)

change_batch = Batch.new(self, health_checks: @options.health_checks, logger: @options.logger, dry_run: @options.dry_run)
self.rrsets.each do |record|
record.delete
change_batch.delete(record)
end

change_batch.request!(@options.route53)

unless @options.dry_run
@options.route53.delete_hosted_zone(id: @hosted_zone.id)
@options.updated = true

0 comments on commit bacf761

Please sign in to comment.
You can’t perform that action at this time.