-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Bug: azurerm_frontdoor
fix for caching issue
#5358
Changes from 1 commit
465d09e
4904a20
f62f456
c85c9c1
cfe157d
ff57240
d9aecd8
17c05f6
e46221e
b88ef6b
5e21698
5b17a51
644ac71
8ef9e23
9cf59c2
2ca5437
e8978c5
ba86c82
6c9af26
9923e35
ffafcb9
20032ed
dadf851
3eb71d9
fe605a3
9c358bd
6adb437
8efc0ac
613bc0e
3412cf1
b2eda4f
4b6ecba
a2e78b0
2c4f4f4
efdfb58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package frontdoor | |
import ( | ||
"fmt" | ||
"log" | ||
"strings" | ||
"time" | ||
|
||
"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2019-04-01/frontdoor" | ||
|
@@ -172,24 +173,25 @@ func resourceArmFrontDoor() *schema.Resource { | |
Required: true, | ||
ValidateFunc: ValidateBackendPoolRoutingRuleName, | ||
}, | ||
// Remove default value for #4461 | ||
"cache_use_dynamic_compression": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
}, | ||
// Remove default value for #4461 | ||
"cache_query_parameter_strip_directive": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(frontdoor.StripAll), | ||
string(frontdoor.StripNone), | ||
}, false), | ||
Default: string(frontdoor.StripNone), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a breaking change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
}, | ||
"custom_forwarding_path": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
// Added Portal Default value for #4627 | ||
"forwarding_protocol": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
|
@@ -198,7 +200,7 @@ func resourceArmFrontDoor() *schema.Resource { | |
string(frontdoor.HTTPSOnly), | ||
string(frontdoor.MatchRequest), | ||
}, false), | ||
Default: string(frontdoor.MatchRequest), | ||
Default: string(frontdoor.HTTPSOnly), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a breaking change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but the entire cache section it totally broken and this change enables the disabling of the cache. Currently there is no way to disable cache with the originally released resource. |
||
}, | ||
}, | ||
}, | ||
|
@@ -596,7 +598,7 @@ func resourceArmFrontDoorRead(d *schema.ResourceData, meta interface{}) error { | |
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) | ||
defer cancel() | ||
|
||
id, err := azure.ParseAzureResourceID(d.Id()) | ||
id, err := ParseAzureResourceIDLowerPath(d.Id()) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -668,7 +670,7 @@ func resourceArmFrontDoorDelete(d *schema.ResourceData, meta interface{}) error | |
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) | ||
defer cancel() | ||
|
||
id, err := azure.ParseAzureResourceID(d.Id()) | ||
id, err := ParseAzureResourceIDLowerPath(d.Id()) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -1050,32 +1052,29 @@ func expandArmFrontDoorForwardingConfiguration(input []interface{}, frontDoorPat | |
|
||
customForwardingPath := v["custom_forwarding_path"].(string) | ||
forwardingProtocol := v["forwarding_protocol"].(string) | ||
backendPoolName := v["backend_pool_name"].(string) | ||
cacheUseDynamicCompression := v["cache_use_dynamic_compression"].(bool) | ||
cacheQueryParameterStripDirective := v["cache_query_parameter_strip_directive"].(string) | ||
backendPoolName := v["backend_pool_name"].(string) | ||
|
||
useDynamicCompression := frontdoor.DynamicCompressionEnabledDisabled | ||
|
||
if cacheUseDynamicCompression { | ||
useDynamicCompression = frontdoor.DynamicCompressionEnabledEnabled | ||
} | ||
|
||
cacheConfiguration := &frontdoor.CacheConfiguration{ | ||
QueryParameterStripDirective: frontdoor.Query(cacheQueryParameterStripDirective), | ||
DynamicCompression: useDynamicCompression, | ||
} | ||
|
||
backend := &frontdoor.SubResource{ | ||
ID: utils.String(frontDoorPath + "/BackendPools/" + backendPoolName), | ||
} | ||
|
||
forwardingConfiguration := frontdoor.ForwardingConfiguration{ | ||
ForwardingProtocol: frontdoor.ForwardingProtocol(forwardingProtocol), | ||
CacheConfiguration: cacheConfiguration, | ||
BackendPool: backend, | ||
OdataType: frontdoor.OdataTypeMicrosoftAzureFrontDoorModelsFrontdoorForwardingConfiguration, | ||
} | ||
|
||
// Per the portal, if you enable the cache the cache_query_parameter_strip_directive | ||
// is then a required attribute else the CacheConfiguration type is null | ||
if cacheUseDynamicCompression { | ||
forwardingConfiguration.CacheConfiguration = &frontdoor.CacheConfiguration{ | ||
DynamicCompression: frontdoor.DynamicCompressionEnabledEnabled, | ||
QueryParameterStripDirective: frontdoor.Query(cacheQueryParameterStripDirective), | ||
} | ||
} | ||
|
||
if customForwardingPath != "" { | ||
forwardingConfiguration.CustomForwardingPath = utils.String(customForwardingPath) | ||
} | ||
|
@@ -1409,11 +1408,11 @@ func flattenArmFrontDoorSubResource(input *frontdoor.SubResource, resourceType s | |
name := "" | ||
|
||
if id := input.ID; id != nil { | ||
aid, err := azure.ParseAzureResourceID(*id) | ||
aid, err := ParseAzureResourceIDLowerPath(*id) | ||
if err != nil { | ||
return "" | ||
} | ||
name = aid.Path[resourceType] | ||
name = aid.Path[strings.ToLower(resourceType)] | ||
} | ||
|
||
return name | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,41 +70,41 @@ resource "azurerm_frontdoor" "example" { | |
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) Name of the Front Door which is globally unique. Changing this forces a new resource to be created. | ||
* `name` - (Required) Specifies the name of the `Front Door` service. Changing this forces a new resource to be created. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `resource_group_name` - (Required) Name of the Resource group within the Azure subscription. Changing this forces a new resource to be created. | ||
* `resource_group_name` - (Required) Specifies the name of the Resource Group in which the `Front Door` service should exist. Changing this forces a new resource to be created. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `location` - (Required) Resource location. Changing this forces a new resource to be created. | ||
* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. | ||
|
||
* `backend_pool` - (Required) A `backend_pool` block as defined below. | ||
|
||
* `backend_pool_health_probe` - (Required) A `backend_pool_health_probe` block as defined below. | ||
|
||
* `backend_pool_load_balancing` - (Required) A `backend_pool_load_balancing` block as defined below. | ||
|
||
* `enforce_backend_pools_certificate_name_check` - (Required) Whether to enforce certificate name check on HTTPS requests to all backend pools. No effect on non-HTTPS requests. Permitted values are `true` or `false`. | ||
* `enforce_backend_pools_certificate_name_check` - (Required) Enforce certificate name check on `HTTPS` requests to all backend pools, this setting will have no effect on `HTTP` requests. Permitted values are `true` or `false`. | ||
|
||
* `load_balancer_enabled` - (Optional) Operational status of the Front Door load balancer. Permitted values are `true` or `false` Defaults to `true`. | ||
* `load_balancer_enabled` - (Optional) Operational status of the `Front Door` load balancer. Permitted values are `true` or `false` Defaults to `true`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `friendly_name` - (Optional) A friendly name for the Front Door service. | ||
* `friendly_name` - (Optional) A friendly name for the `Front Door` service. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `frontend_endpoint` - (Required) A `frontend_endpoint` block as defined below. | ||
|
||
* `routing_rule` - (Required) A `routing_rule` block as defined below. | ||
|
||
* `tags` - (Optional) Resource tags. | ||
* `tags` - (Optional) A mapping of tags to assign to the resource. | ||
|
||
--- | ||
|
||
The `backend_pool` block supports the following: | ||
|
||
* `name` - (Required) The name of the `Backend Pool`. | ||
* `name` - (Required) Specifies the name of the name of the `Backend Pool`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `backend` - (Required) A `backend` block as defined below. | ||
|
||
* `load_balancing_name` - (Required) The name property of the `backend_pool_load_balancing` block whithin this resource to use for the `Backend Pool`. | ||
* `load_balancing_name` - (Required) Specifies the name of the `backend_pool_load_balancing` block whithin this resource to use for this `Backend Pool`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `health_probe_name` - (Required) The name property of a `backend_pool_health_probe` block whithin this resource to use for the `Backend Pool`. | ||
* `health_probe_name` - (Required) Specifies the name of the `backend_pool_health_probe` block whithin this resource to use for this `Backend Pool`. | ||
|
||
--- | ||
|
||
|
@@ -126,35 +126,37 @@ The `backend` block supports the following: | |
|
||
The `frontend_endpoint` block supports the following: | ||
|
||
* `name` - (Required) The name of the Frontend Endpoint. | ||
* `name` - (Required) Specifies the name of the `frontend_endpoint`. | ||
|
||
* `host_name` - (Required) The host name of the Frontend Endpoint. Must be a domain name. | ||
|
||
* `custom_https_provisioning_enabled` - (Required) Whether to allow HTTPS protocol for a custom domain that's associated with Front Door to ensure sensitive data is delivered securely via TLS/SSL encryption when sent across the internet. Valid options are `true` or `false`. | ||
* `host_name` - (Required) Specifies the host name of the `frontend_endpoint`. Must be a domain name. | ||
|
||
* `session_affinity_enabled` - (Optional) Whether to allow session affinity on this host. Valid options are `true` or `false` Defaults to `false`. | ||
|
||
* `session_affinity_ttl_seconds` - (Optional) The TTL to use in seconds for session affinity, if applicable. Defaults to `0`. | ||
|
||
* `custom_https_provisioning_enabled` - (Required) Whether to allow HTTPS protocol for a custom domain that's associated with Front Door to ensure sensitive data is delivered securely via TLS/SSL encryption when sent across the internet. Valid options are `true` or `false`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `custom_https_configuration` - (Optional) A `custom_https_configuration` block as defined below. This block is required if the `custom_https_provisioning_enabled` is set to `true`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `web_application_firewall_policy_link_id` - (Optional) Defines the Web Application Firewall policy `ID` for each host. | ||
|
||
--- | ||
|
||
The `backend_pool_health_probe` block supports the following: | ||
|
||
* `name` - (Required) The name of the Azure Front Door Backend Health Probe. | ||
* `name` - (Required) Specifies the name of the `backend_pool_health_probe`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `path` - (Optional) The path to use for the Backend Health Probe. Default is `/`. | ||
* `path` - (Optional) The path to use for the `backend_pool_health_probe`. Default is `/`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `protocol` - (Optional) Protocol scheme to use for the Backend Health Probe. Defaults to `Http`. | ||
* `protocol` - (Optional) Protocol scheme to use for the `backend_pool_health_probe`. Defaults to `Http`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `interval_in_seconds` - (Optional) The number of seconds between health probes. Defaults to `120`. | ||
* `interval_in_seconds` - (Optional) The number of seconds between the `backend_pool_health_probe` probes. Defaults to `120`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
--- | ||
|
||
The `backend_pool_load_balancing` block supports the following: | ||
|
||
* `name` - (Required) The name of the Azure Front Door Backend Load Balancer. | ||
* `name` - (Required) Specifies the name of the `backend_pool_load_balancing`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `sample_size` - (Optional) The number of samples to consider for load balancing decisions. Defaults to `4`. | ||
|
||
|
@@ -166,7 +168,7 @@ The `backend_pool_load_balancing` block supports the following: | |
|
||
The `routing_rule` block supports the following: | ||
|
||
* `name` - (Required) The name of the Front Door Backend Routing Rule. | ||
* `name` - (Required) Specifies the name of the `routing_rule`. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `frontend_endpoints` - (Required) The names of the `frontend_endpoint` blocks whithin this resource to associate with this `routing_rule`. | ||
|
||
|
@@ -184,23 +186,23 @@ The `routing_rule` block supports the following: | |
|
||
The `forwarding_configuration` block supports the following: | ||
|
||
* `backend_pool_name` - (Required) The name of the Front Door Backend Pool. | ||
* `backend_pool_name` - (Required) Specifies the name of the `backend_pool` to forward the incoming traffic to. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `cache_use_dynamic_compression` - (Optional) Whether to use dynamic compression when caching. Valid options are `true` or `false`. Defaults to `true`. | ||
* `cache_use_dynamic_compression` - (Optional) Whether to use dynamic compression when caching. Valid options are `true` or `false`. Defaults to `false`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this was a documentation error, as in the schema in master the default value is also false. So I think this is good. |
||
|
||
* `cache_query_parameter_strip_directive` - (Optional) Defines cache behavior in releation to query string parameters. Valid options are `StripAll` or `StripNone`. Defaults to `StripNone` | ||
* `cache_query_parameter_strip_directive` - (Optional) Defines cache behavior in releation to query string parameters. Valid options are `StripAll` or `StripNone`. | ||
|
||
* `custom_forwarding_path` - (Optional) Path to use when constructing the request to forward to the backend. This functions as a URL Rewrite. Default behavior preserves the URL path. | ||
|
||
* `forwarding_protocol` - (Optional) Protocol to use when redirecting. Valid options are `HttpOnly`, `HttpsOnly`, or `MatchRequest`. Defaults to `MatchRequest`. | ||
* `forwarding_protocol` - (Optional) Protocol to use when redirecting. Valid options are `HTTPOnly`, `HTTPSOnly`, or `MatchRequest`. Defaults to `HTTPSOnly`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these aren't the values from the SDK:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
||
--- | ||
|
||
The `redirect_configuration` block supports the following: | ||
|
||
* `custom_host` - (Optional) Set this to change the URL for the redirection. | ||
|
||
* `redirect_protocol` - (Optional) Protocol to use when redirecting. Valid options are `HttpOnly`, `HttpsOnly`, `MatchRequest`. Defaults to `MatchRequest` | ||
* `redirect_protocol` - (Optional) Protocol to use when redirecting. Valid options are `HTTPOnly`, `HTTPSOnly`, `MatchRequest`. Defaults to `MatchRequest` | ||
|
||
* `redirect_type` - (Optional) Status code for the redirect. Valida options are `Moved`, `Found`, `TemporaryRedirect`, `PermanentRedirect`. Defaults to `Found` | ||
|
||
|
@@ -218,7 +220,7 @@ The `custom_https_configuration` block supports the following: | |
|
||
The following attributes are only valid if `certificate_source` is set to `AzureKeyVault`: | ||
|
||
* `azure_key_vault_certificate_vault_id` - (Required) The `id` of the Key Vault containing the SSL certificate. | ||
* `azure_key_vault_certificate_vault_id` - (Required) The `ID` of the Key Vault containing the SSL certificate. | ||
WodansSon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* `azure_key_vault_certificate_secret_name` - (Required) The name of the Key Vault secret representing the full certificate PFX. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since there's two possible values for this - it'd be better to instead check both of the specific casings we need here e.g.
if we wrap this in an ID parsing function (e.g. as shown in #5356) we should be able to instead reuse the existing function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.