I'm currently using Fog to manage Dyn DNS provider. According the documentation, there's a destroy
method on the DNS record object. However, when I call destroy
, on a record, nothing happens... the method just returns true, but it is never deleted. Here's the code I'm using:
@dynect = Fog::DNS.new(
:provider => "dynect",
:dynect_customer => "CUSTOMER",
:dynect_username => "USERNAME",
:dynect_password => 'PASSWORD'
)
@zone = @dynect.zones.get('zone.example.com')
@record = @zone.records.find{|r| r.name == 'master.zone.example.com' && r.type == 'CNAME'}
@record.destroy
@zone.save
This will return true, but nothing ever happens - the DNS record still exists on Dyn.
How do I delete a record with Fog and Dyn?
Turns out you need to then publish (not save) the zone... This is not obvious, since other providers, like AWS, don't require. Here's an updated code snippet:
@dynect = Fog::DNS.new(
:provider => "dynect",
:dynect_customer => "CUSTOMER",
:dynect_username => "USERNAME",
:dynect_password => 'PASSWORD'
)
@zone = @dynect.zones.get('zone.example.com')
@record = @zone.records.find{|r| r.name == 'master.zone.example.com' && r.type == 'CNAME'}
@record.destroy
@zone.publish # changed this