Skip to content

Commit

Permalink
fixes #4558
Browse files Browse the repository at this point in the history
* Update Frontdoor API version

* Exposed SendRecvTimeoutSeconds

* Add comment to code and add note to docs
  • Loading branch information
WodansSon authored Apr 29, 2020
1 parent be1ea78 commit fa644aa
Show file tree
Hide file tree
Showing 21 changed files with 1,097 additions and 44 deletions.
2 changes: 1 addition & 1 deletion azurerm/internal/services/frontdoor/client/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2019-11-01/frontdoor"
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-01-01/frontdoor"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)

Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/frontdoor/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package frontdoor
import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2019-11-01/frontdoor"
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-01-01/frontdoor"
)

func IsFrontDoorFrontendEndpointConfigurable(currentState frontdoor.CustomHTTPSProvisioningState, customHttpsProvisioningEnabled bool, frontendEndpointName string, resourceGroup string) error {
Expand Down
50 changes: 38 additions & 12 deletions azurerm/internal/services/frontdoor/resource_arm_frontdoor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2019-11-01/frontdoor"
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-01-01/frontdoor"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down Expand Up @@ -62,12 +62,22 @@ func resourceArmFrontDoor() *schema.Resource {
Default: true,
},

// TODO: In 3.0
// Move 'enforce_backend_pools_certificate_name_check' and 'backend_pools_send_receive_timeout_seconds'
// into a 'backend_pool_settings' block
"enforce_backend_pools_certificate_name_check": {
Type: schema.TypeBool,
Required: true,
},

// remove in 3.0
"backend_pools_send_receive_timeout_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: 60,
ValidateFunc: validation.IntBetween(0, 240),
},

// TODO: Remove in 3.0
"location": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -527,6 +537,7 @@ func resourceArmFrontDoorCreateUpdate(d *schema.ResourceData, meta interface{})
backendPools := d.Get("backend_pool").([]interface{})
frontendEndpoints := d.Get("frontend_endpoint").([]interface{})
backendPoolsSettings := d.Get("enforce_backend_pools_certificate_name_check").(bool)
backendPoolsSendReceiveTimeoutSeconds := int32(d.Get("backend_pools_send_receive_timeout_seconds").(int))
enabledState := d.Get("load_balancer_enabled").(bool)

t := d.Get("tags").(map[string]interface{})
Expand All @@ -537,7 +548,7 @@ func resourceArmFrontDoorCreateUpdate(d *schema.ResourceData, meta interface{})
FriendlyName: utils.String(friendlyName),
RoutingRules: expandArmFrontDoorRoutingRule(routingRules, frontDoorPath),
BackendPools: expandArmFrontDoorBackendPools(backendPools, frontDoorPath),
BackendPoolsSettings: expandArmFrontDoorBackendPoolsSettings(backendPoolsSettings),
BackendPoolsSettings: expandArmFrontDoorBackendPoolsSettings(backendPoolsSettings, backendPoolsSendReceiveTimeoutSeconds),
FrontendEndpoints: expandArmFrontDoorFrontendEndpoint(frontendEndpoints, frontDoorPath),
HealthProbeSettings: expandArmFrontDoorHealthProbeSettingsModel(healthProbeSettings, frontDoorPath),
LoadBalancingSettings: expandArmFrontDoorLoadBalancingSettingsModel(loadBalancingSettings, frontDoorPath),
Expand Down Expand Up @@ -683,10 +694,16 @@ func resourceArmFrontDoorRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("setting `backend_pool`: %+v", err)
}

if err := d.Set("enforce_backend_pools_certificate_name_check", flattenArmFrontDoorBackendPoolsSettings(properties.BackendPoolsSettings)); err != nil {
backendPoolSettings := flattenArmFrontDoorBackendPoolsSettings(properties.BackendPoolsSettings)

if err := d.Set("enforce_backend_pools_certificate_name_check", backendPoolSettings["enforce_backend_pools_certificate_name_check"].(bool)); err != nil {
return fmt.Errorf("setting `enforce_backend_pools_certificate_name_check`: %+v", err)
}

if err := d.Set("backend_pools_send_receive_timeout_seconds", backendPoolSettings["backend_pools_send_receive_timeout_seconds"].(int32)); err != nil {
return fmt.Errorf("setting `backend_pools_send_receive_timeout_seconds`: %+v", err)
}

d.Set("cname", properties.Cname)
d.Set("load_balancer_enabled", properties.EnabledState == frontdoor.EnabledStateEnabled)
d.Set("friendly_name", properties.FriendlyName)
Expand Down Expand Up @@ -832,7 +849,7 @@ func expandArmFrontDoorBackendEnabledState(isEnabled bool) frontdoor.BackendEnab
return frontdoor.Disabled
}

func expandArmFrontDoorBackendPoolsSettings(enforceCertificateNameCheck bool) *frontdoor.BackendPoolsSettings {
func expandArmFrontDoorBackendPoolsSettings(enforceCertificateNameCheck bool, backendPoolsSendReceiveTimeoutSeconds int32) *frontdoor.BackendPoolsSettings {
enforceCheck := frontdoor.EnforceCertificateNameCheckEnabledStateDisabled

if enforceCertificateNameCheck {
Expand All @@ -841,6 +858,7 @@ func expandArmFrontDoorBackendPoolsSettings(enforceCertificateNameCheck bool) *f

result := frontdoor.BackendPoolsSettings{
EnforceCertificateNameCheck: enforceCheck,
SendRecvTimeoutSeconds: utils.Int32(backendPoolsSendReceiveTimeoutSeconds),
}

return &result
Expand Down Expand Up @@ -1180,17 +1198,25 @@ func flattenArmFrontDoorBackendPools(input *[]frontdoor.BackendPool) []map[strin
return output
}

func flattenArmFrontDoorBackendPoolsSettings(input *frontdoor.BackendPoolsSettings) bool {
func flattenArmFrontDoorBackendPoolsSettings(input *frontdoor.BackendPoolsSettings) map[string]interface{} {
result := make(map[string]interface{})

// Set default values
result["enforce_backend_pools_certificate_name_check"] = true
result["backend_pools_send_receive_timeout_seconds"] = int32(60)

if input == nil {
return true
return result
}

result := false
result["enforce_backend_pools_certificate_name_check"] = false

if enforceCertificateNameCheck := input.EnforceCertificateNameCheck; enforceCertificateNameCheck != "" {
if enforceCertificateNameCheck == frontdoor.EnforceCertificateNameCheckEnabledStateEnabled {
result = true
}
if enforceCertificateNameCheck := input.EnforceCertificateNameCheck; enforceCertificateNameCheck != "" && enforceCertificateNameCheck == frontdoor.EnforceCertificateNameCheckEnabledStateEnabled {
result["enforce_backend_pools_certificate_name_check"] = true
}

if sendRecvTimeoutSeconds := input.SendRecvTimeoutSeconds; sendRecvTimeoutSeconds != nil {
result["backend_pools_send_receive_timeout_seconds"] = *sendRecvTimeoutSeconds
}

return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2019-11-01/frontdoor"
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-01-01/frontdoor"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ resource "azurerm_frontdoor" "test" {
name = "acctest-FD-%d"
resource_group_name = azurerm_resource_group.test.name
enforce_backend_pools_certificate_name_check = false
backend_pools_send_receive_timeout_seconds = 45
routing_rule {
name = "routing-rule"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/frontdoor/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2019-11-01/frontdoor"
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-01-01/frontdoor"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fa644aa

Please sign in to comment.