Skip to content

Commit

Permalink
Merge pull request #4590 from vaishakdinesh/vaishak/zone-dns-sec
Browse files Browse the repository at this point in the history
Fix: testdata and custom code
  • Loading branch information
jacobbednarz authored Nov 19, 2024
2 parents d3f9ad7 + 16f8f8d commit 7ebef0e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
27 changes: 27 additions & 0 deletions internal/services/zone_dnssec/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package zone_dnssec

import (
"context"

"github.com/cloudflare/cloudflare-go/v3"
"github.com/cloudflare/cloudflare-go/v3/dnssec"
"github.com/cloudflare/cloudflare-go/v3/option"
"github.com/cloudflare/terraform-provider-cloudflare/internal/logging"
"github.com/hashicorp/terraform-plugin-framework/resource"
)

func disableDNSSECRecord(ctx context.Context, r *ZoneDNSSECResource, zoneID string, resp *resource.DeleteResponse) {
var err error
_, err = r.client.DNSSEC.Edit(
ctx,
dnssec.DNSSECEditParams{
ZoneID: cloudflare.F(zoneID),
Status: cloudflare.F[dnssec.DNSSECEditParamsStatus](dnssec.DNSSECEditParamsStatusDisabled),
},
option.WithMiddleware(logging.Middleware(ctx)),
)
if err != nil {
resp.Diagnostics.AddError("failed to make http request", err.Error())
return
}
}
2 changes: 2 additions & 0 deletions internal/services/zone_dnssec/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func (r *ZoneDNSSECResource) Delete(ctx context.Context, req resource.DeleteRequ
return
}

disableDNSSECRecord(ctx, r, data.ZoneID.ValueString(), resp)

_, err := r.client.DNSSEC.Delete(
ctx,
dnssec.DNSSECDeleteParams{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "cloudflare_zone_dnssec" "%[1]s" {
zone_id = "%[2]s"
status = "active"
}

data "cloudflare_zone_dnssec" "%[1]s" {
zone_id = "%[2]s"
depends_on = [ "cloudflare_dns_zone_dnssec.%[1]s" ]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

resource "cloudflare_zone_dnssec" "%s" {
zone_id = "%s"
status = "active"
}

0 comments on commit 7ebef0e

Please sign in to comment.