Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_frontdoor - Add support for backend_pools_send_receive_timeout_seconds #6604

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
45 changes: 34 additions & 11 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 @@ -67,6 +67,13 @@ func resourceArmFrontDoor() *schema.Resource {
Required: true,
},

"backend_pools_send_receive_timeout_seconds": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be backend_pool_send_receive_timeout_in_seconds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally going to call it that too, but after researching it, it's a global setting for all backend pools thus the plural. 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh see i would have assumed it was applying to all of them without the s, but there is another property backend_pool? which is different the the other back end pools i can see why heh

Type: schema.TypeInt,
Optional: true,
Default: 60,
ValidateFunc: validation.IntBetween(0, 240),
},

// remove in 3.0
"location": {
Type: schema.TypeString,
Expand Down Expand Up @@ -527,6 +534,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 +545,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 +691,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 +846,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 +855,7 @@ func expandArmFrontDoorBackendPoolsSettings(enforceCertificateNameCheck bool) *f

result := frontdoor.BackendPoolsSettings{
EnforceCertificateNameCheck: enforceCheck,
SendRecvTimeoutSeconds: utils.Int32(backendPoolsSendReceiveTimeoutSeconds),
}
Comment on lines 859 to 862
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there more settings here? would it make sense to move this into a backend_pool_configuration block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I was thinking the same thing... but I wanted to avoid a breaking change so I just put it at the top level with the other backend pools settings. Not sure if we should pull it into a block yet, if another setting is exposed in a future API I think it would be appropriate to make the change at that time... Maybe open a 3.0 breaking change issue for this to fix in the future?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well we now have 2 so it makes sense to move into a block (especially when we have such long names) if we did it in 3.0 we would still ideally want to depreacate the old properties & support both so people have a migration path.


return &result
Expand Down Expand Up @@ -1180,17 +1195,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