Skip to content

Commit

Permalink
update to ssl pending verification check
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bluem committed Oct 12, 2022
1 parent 4d7f949 commit f5a7089
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .changelog/1953.txt
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 1 addition & 1 deletion docs/resources/custom_hostname.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_cloudflare_custom_hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_cloudflare_custom_hostname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/schema_cloudflare_custom_hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
}
}

0 comments on commit f5a7089

Please sign in to comment.