Skip to content

Commit

Permalink
r/frontdoor: using a consistent read-timeout of 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Jun 25, 2020
1 parent 127eb47 commit a08a2d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions azurerm/internal/services/frontdoor/frontdoor_resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package frontdoor

import (
"context"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -33,7 +34,7 @@ func resourceArmFrontDoor() *schema.Resource {

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(6 * time.Hour),
Read: schema.DefaultTimeout(6 * time.Hour),
Read: schema.DefaultTimeout(5 * time.Minute),
Update: schema.DefaultTimeout(6 * time.Hour),
Delete: schema.DefaultTimeout(6 * time.Hour),
},
Expand Down Expand Up @@ -620,12 +621,12 @@ func resourceArmFrontDoorCreateUpdate(d *schema.ResourceData, meta interface{})
}
customHTTPSConfigurationUpdate := makeCustomHttpsConfiguration(customHTTPSConfiguration, minTLSVersion)
// Enable Custom Domain HTTPS for the Frontend Endpoint
if err := resourceArmFrontDoorFrontendEndpointEnableHttpsProvisioning(d, true, name, frontendEndpointName, resourceGroup, customHTTPSConfigurationUpdate, meta); err != nil {
if err := resourceArmFrontDoorFrontendEndpointEnableHttpsProvisioning(ctx, d, true, name, frontendEndpointName, resourceGroup, customHTTPSConfigurationUpdate, meta); err != nil {
return fmt.Errorf("Unable enable Custom Domain HTTPS for Frontend Endpoint %q (Resource Group %q): %+v", frontendEndpointName, resourceGroup, err)
}
} else if !customHttpsProvisioningEnabled && provisioningState == frontdoor.CustomHTTPSProvisioningStateEnabled {
// Disable Custom Domain HTTPS for the Frontend Endpoint
if err := resourceArmFrontDoorFrontendEndpointEnableHttpsProvisioning(d, false, name, frontendEndpointName, resourceGroup, frontdoor.CustomHTTPSConfiguration{}, meta); err != nil {
if err := resourceArmFrontDoorFrontendEndpointEnableHttpsProvisioning(ctx, d, false, name, frontendEndpointName, resourceGroup, frontdoor.CustomHTTPSConfiguration{}, meta); err != nil {
return fmt.Errorf("Unable to disable Custom Domain HTTPS for Frontend Endpoint %q (Resource Group %q): %+v", frontendEndpointName, resourceGroup, err)
}
}
Expand All @@ -636,10 +637,8 @@ func resourceArmFrontDoorCreateUpdate(d *schema.ResourceData, meta interface{})
return resourceArmFrontDoorRead(d, meta)
}

func resourceArmFrontDoorFrontendEndpointEnableHttpsProvisioning(d *schema.ResourceData, enableCustomHttpsProvisioning bool, frontDoorName string, frontendEndpointName string, resourceGroup string, customHTTPSConfiguration frontdoor.CustomHTTPSConfiguration, meta interface{}) error {
func resourceArmFrontDoorFrontendEndpointEnableHttpsProvisioning(ctx context.Context, d *schema.ResourceData, enableCustomHttpsProvisioning bool, frontDoorName string, frontendEndpointName string, resourceGroup string, customHTTPSConfiguration frontdoor.CustomHTTPSConfiguration, meta interface{}) error {
client := meta.(*clients.Client).Frontdoor.FrontDoorsFrontendClient
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

if enableCustomHttpsProvisioning {
future, err := client.EnableHTTPS(ctx, resourceGroup, frontDoorName, frontendEndpointName, customHTTPSConfiguration)
Expand Down Expand Up @@ -716,7 +715,7 @@ func resourceArmFrontDoorRead(d *schema.ResourceData, meta interface{}) error {

if frontendEndpoints := properties.FrontendEndpoints; frontendEndpoints != nil {
if resp.Name != nil {
if frontDoorFrontendEndpoints, err := flattenArmFrontDoorFrontendEndpoint(d, frontendEndpoints, resourceGroup, *resp.Name, meta); frontDoorFrontendEndpoints != nil {
if frontDoorFrontendEndpoints, err := flattenArmFrontDoorFrontendEndpoint(ctx, d, frontendEndpoints, resourceGroup, *resp.Name, meta); frontDoorFrontendEndpoints != nil {
if err := d.Set("frontend_endpoint", frontDoorFrontendEndpoints); err != nil {
return fmt.Errorf("setting `frontend_endpoint`: %+v", err)
}
Expand Down Expand Up @@ -1269,7 +1268,7 @@ func flattenArmFrontDoorBackend(input *[]frontdoor.Backend) []interface{} {
return output
}

func flattenArmFrontDoorFrontendEndpoint(d *schema.ResourceData, input *[]frontdoor.FrontendEndpoint, resourceGroup string, frontDoorName string, meta interface{}) ([]interface{}, error) {
func flattenArmFrontDoorFrontendEndpoint(ctx context.Context, d *schema.ResourceData, input *[]frontdoor.FrontendEndpoint, resourceGroup string, frontDoorName string, meta interface{}) ([]interface{}, error) {
if input == nil {
return make([]interface{}, 0), fmt.Errorf("cannot read Front Door Frontend Endpoint (Resource Group %q): slice is empty", resourceGroup)
}
Expand All @@ -1287,8 +1286,6 @@ func flattenArmFrontDoorFrontendEndpoint(d *schema.ResourceData, input *[]frontd
// Need to call frontEndEndpointClient here to get customConfiguration information from that client
// because the information is hidden from the main frontDoorClient "by design"...
client := meta.(*clients.Client).Frontdoor.FrontDoorsFrontendClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

resp, err := client.Get(ctx, resourceGroup, frontDoorName, *name)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/frontdoor.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d

* `create` - (Defaults to 6 hours) Used when creating the FrontDoor.
* `update` - (Defaults to 6 hours) Used when updating the FrontDoor.
* `read` - (Defaults to 6 hours) Used when retrieving the FrontDoor.
* `read` - (Defaults to 5 minutes) Used when retrieving the FrontDoor.
* `delete` - (Defaults to 6 hours) Used when deleting the FrontDoor.

## Import
Expand Down

0 comments on commit a08a2d8

Please sign in to comment.