diff --git a/providers/dns/oraclecloud/oraclecloud.go b/providers/dns/oraclecloud/oraclecloud.go index bcd0c058..c48a6291 100644 --- a/providers/dns/oraclecloud/oraclecloud.go +++ b/providers/dns/oraclecloud/oraclecloud.go @@ -85,6 +85,11 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + zoneNameOrID, err1 := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + if err1 != nil { + return fmt.Errorf("oraclecloud: could not find zone for domain %q and fqdn %q : %w", domain, fqdn, err1) + } + // generate request to dns.PatchDomainRecordsRequest recordOperation := dns.RecordOperation{ Domain: common.String(dns01.UnFqdn(fqdn)), @@ -96,7 +101,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { request := dns.PatchDomainRecordsRequest{ CompartmentId: common.String(d.config.CompartmentID), - ZoneNameOrId: common.String(domain), + ZoneNameOrId: common.String(zoneNameOrID), Domain: common.String(dns01.UnFqdn(fqdn)), PatchDomainRecordsDetails: dns.PatchDomainRecordsDetails{ Items: []dns.RecordOperation{recordOperation}, @@ -115,9 +120,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + zoneNameOrID, err1 := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + if err1 != nil { + return fmt.Errorf("oraclecloud: could not find zone for domain %q and fqdn %q : %w", domain, fqdn, err1) + } + // search to TXT record's hash to delete getRequest := dns.GetDomainRecordsRequest{ - ZoneNameOrId: common.String(domain), + ZoneNameOrId: common.String(zoneNameOrID), Domain: common.String(dns01.UnFqdn(fqdn)), CompartmentId: common.String(d.config.CompartmentID), Rtype: common.String("TXT"), @@ -152,7 +162,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } patchRequest := dns.PatchDomainRecordsRequest{ - ZoneNameOrId: common.String(domain), + ZoneNameOrId: common.String(zoneNameOrID), Domain: common.String(dns01.UnFqdn(fqdn)), PatchDomainRecordsDetails: dns.PatchDomainRecordsDetails{ Items: []dns.RecordOperation{recordOperation},