From 1b362892e655dcc24c57cd38331a3b5dbe920571 Mon Sep 17 00:00:00 2001 From: Francis Chuang Date: Fri, 30 Dec 2022 13:23:58 +1100 Subject: [PATCH] Add customizable create and delete timeouts for DNS zone and DNS zone record resources --- docs/resources/gcore_dns_zone.md | 12 ++++++++++++ docs/resources/gcore_dns_zone_record.md | 10 ++++++++++ gcore/resource_gcore_dns_zone.go | 5 +++++ gcore/resource_gcore_dns_zone_record.go | 5 +++++ 4 files changed, 32 insertions(+) diff --git a/docs/resources/gcore_dns_zone.md b/docs/resources/gcore_dns_zone.md index 6252e38..6a3d372 100644 --- a/docs/resources/gcore_dns_zone.md +++ b/docs/resources/gcore_dns_zone.md @@ -29,10 +29,22 @@ resource "gcore_dns_zone" "example_zone" { - `name` (String) A name of DNS Zone resource. +### Optional + +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) + ### Read-Only - `id` (String) The ID of this resource. + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `delete` (String) + ## Import Import is supported using the following syntax: diff --git a/docs/resources/gcore_dns_zone_record.md b/docs/resources/gcore_dns_zone_record.md index 67d7fcc..c7f8cb4 100644 --- a/docs/resources/gcore_dns_zone_record.md +++ b/docs/resources/gcore_dns_zone_record.md @@ -113,6 +113,7 @@ resource "gcore_dns_zone_record" "subdomain_examplezone_caa" { ### Optional - `filter` (Block Set) (see [below for nested schema](#nestedblock--filter)) +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `ttl` (Number) A ttl of DNS Zone Record resource. ### Read-Only @@ -158,6 +159,15 @@ Optional: - `limit` (Number) A DNS Zone Record filter option that describe how many records will be percolated. - `strict` (Boolean) A DNS Zone Record filter option that describe possibility to return answers if no records were percolated through filter. + + +### Nested Schema for `timeouts` + +Optional: + +- `create` (String) +- `delete` (String) + ## Import Import is supported using the following syntax: diff --git a/gcore/resource_gcore_dns_zone.go b/gcore/resource_gcore_dns_zone.go index 9857277..b55945a 100644 --- a/gcore/resource_gcore_dns_zone.go +++ b/gcore/resource_gcore_dns_zone.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strings" + "time" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -33,6 +34,10 @@ func resourceDNSZone() *schema.Resource { Description: "A name of DNS Zone resource.", }, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + }, CreateContext: checkDNSDependency(resourceDNSZoneCreate), ReadContext: checkDNSDependency(resourceDNSZoneRead), DeleteContext: checkDNSDependency(resourceDNSZoneDelete), diff --git a/gcore/resource_gcore_dns_zone_record.go b/gcore/resource_gcore_dns_zone_record.go index 1f5b722..b15f329 100644 --- a/gcore/resource_gcore_dns_zone_record.go +++ b/gcore/resource_gcore_dns_zone_record.go @@ -7,6 +7,7 @@ import ( "log" "net" "strings" + "time" dnssdk "github.com/G-Core/gcore-dns-sdk-go" "github.com/hashicorp/go-cty/cty" @@ -232,6 +233,10 @@ func resourceDNSZoneRecord() *schema.Resource { Description: "An array of contents with meta of DNS Zone Record resource.", }, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + }, CreateContext: checkDNSDependency(resourceDNSZoneRecordCreate), UpdateContext: checkDNSDependency(resourceDNSZoneRecordUpdate), ReadContext: checkDNSDependency(resourceDNSZoneRecordRead),