diff --git a/.changelog/1953.txt b/.changelog/1953.txt index 8cb66aa17b..cb5fd7ad1e 100644 --- a/.changelog/1953.txt +++ b/.changelog/1953.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/cloudflare_custom_hostname: Add `wait_for_active_status` attribute +resource/cloudflare_custom_hostname: Add `wait_for_ssl_pending_validation` attribute ``` \ No newline at end of file diff --git a/docs/resources/custom_hostname.md b/docs/resources/custom_hostname.md index c8546cca5e..8fc8ce121e 100644 --- a/docs/resources/custom_hostname.md +++ b/docs/resources/custom_hostname.md @@ -33,7 +33,7 @@ resource "cloudflare_custom_hostname" "example" { - `custom_origin_server` (String) The custom origin server used for certificates. - `custom_origin_sni` (String) The [custom origin SNI](https://developers.cloudflare.com/ssl/ssl-for-saas/hostname-specific-behavior/custom-origin) used for certificates. - `ssl` (Block List) SSL configuration of the certificate. (see [below for nested schema](#nestedblock--ssl)) -- `wait_for_active_status` (Boolean) Whether to wait for a custom hostname to reach `active` state during creation. Defaults to `false`. +- `wait_for_ssl_pending_validation` (Boolean) Whether or not to wait for a custom hostname SSL sub-object to reach status `pending_validation` during creation. Defaults to `false`. ### Read-Only diff --git a/internal/provider/resource_cloudflare_custom_hostname.go b/internal/provider/resource_cloudflare_custom_hostname.go index 310f0ea6ab..d76cb705be 100644 --- a/internal/provider/resource_cloudflare_custom_hostname.go +++ b/internal/provider/resource_cloudflare_custom_hostname.go @@ -140,15 +140,15 @@ func resourceCloudflareCustomHostnameCreate(ctx context.Context, d *schema.Resou hostnameID := newCertificate.Result.ID - if d.Get("wait_for_active_status").(bool) { + if d.Get("wait_for_ssl_pending_validation").(bool) { err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutCreate)-time.Minute, func() *resource.RetryError { customHostname, err := client.CustomHostname(ctx, zoneID, hostnameID) - tflog.Debug(ctx, fmt.Sprintf("custom hostname status %s", customHostname.Status)) + tflog.Debug(ctx, fmt.Sprintf("custom hostname ssl status %s", customHostname.SSL.Status)) if err != nil { return resource.NonRetryableError(errors.Wrap(err, "failed to fetch custom hostname")) } - if customHostname.Status != "active" { - return resource.RetryableError(fmt.Errorf("hostname is not yet in active status")) + if customHostname.SSL.Status != "pending_validation" { + return resource.RetryableError(fmt.Errorf("hostname ssl configuration is not yet in pending_validation status")) } return nil }) diff --git a/internal/provider/resource_cloudflare_custom_hostname_test.go b/internal/provider/resource_cloudflare_custom_hostname_test.go index 423f771deb..26ae1afff5 100644 --- a/internal/provider/resource_cloudflare_custom_hostname_test.go +++ b/internal/provider/resource_cloudflare_custom_hostname_test.go @@ -111,7 +111,7 @@ func TestAccCloudflareCustomHostname_WaitForActive(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "zone_id", zoneID), resource.TestCheckResourceAttr(resourceName, "hostname", fmt.Sprintf("%s.%s", rnd, domain)), resource.TestCheckResourceAttr(resourceName, "ssl.0.method", "txt"), - resource.TestCheckResourceAttr(resourceName, "wait_for_active_status", "true"), + resource.TestCheckResourceAttr(resourceName, "wait_for_ssl_pending_validation", "true"), resource.TestCheckResourceAttrSet(resourceName, "ownership_verification.value"), resource.TestCheckResourceAttrSet(resourceName, "ownership_verification.type"), resource.TestCheckResourceAttrSet(resourceName, "ownership_verification.name"), @@ -131,7 +131,7 @@ resource "cloudflare_custom_hostname" "%[2]s" { ssl { method = "txt" } - wait_for_active_status = true + wait_for_ssl_pending_validation = true } `, zoneID, rnd, domain) } diff --git a/internal/provider/schema_cloudflare_custom_hostname.go b/internal/provider/schema_cloudflare_custom_hostname.go index 41297034fd..c2883313d1 100644 --- a/internal/provider/schema_cloudflare_custom_hostname.go +++ b/internal/provider/schema_cloudflare_custom_hostname.go @@ -155,12 +155,12 @@ func resourceCloudflareCustomHostnameSchema() map[string]*schema.Schema { Computed: true, }, }, - "wait_for_active_status": { + "wait_for_ssl_pending_validation": { Type: schema.TypeBool, ForceNew: true, Optional: true, Default: false, - Description: "Whether to wait for a custom hostname to reach `active` state during creation.", + Description: "Whether or not to wait for a custom hostname SSL sub-object to reach status `pending_validation` during creation.", }, } }