From d5c331add25680f39f41793c632718bd763e95a4 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Fri, 11 Feb 2022 20:28:29 +0000 Subject: [PATCH] Fix rate limiting options values (#5691) Signed-off-by: Modular Magician --- .changelog/5691.txt | 3 +++ .../resource_compute_security_policy.go | 18 ++++++++--------- .../r/compute_security_policy.html.markdown | 20 ++++++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 .changelog/5691.txt diff --git a/.changelog/5691.txt b/.changelog/5691.txt new file mode 100644 index 0000000000..e370738689 --- /dev/null +++ b/.changelog/5691.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: corrected an issue in `google_compute_security_policy` where only alpha values for certain enums were accepted +``` diff --git a/google-beta/resource_compute_security_policy.go b/google-beta/resource_compute_security_policy.go index 82deba6ea7..a06522488d 100644 --- a/google-beta/resource_compute_security_policy.go +++ b/google-beta/resource_compute_security_policy.go @@ -60,10 +60,9 @@ func resourceComputeSecurityPolicy() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "action": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"allow", "deny(403)", "deny(404)", "deny(502)", "rate_based_ban", "throttle"}, false), - Description: `Action to take when match matches the request. Valid values: "allow" : allow access to target, "deny(status)" : deny access to target, returns the HTTP response code specified (valid values are 403, 404 and 502)`, + Type: schema.TypeString, + Required: true, + Description: `Action to take when match matches the request.`, }, "priority": { @@ -194,17 +193,16 @@ func resourceComputeSecurityPolicy() *schema.Resource { }, "enforce_on_key": { - Type: schema.TypeString, - Optional: true, - Default: "ALL", - ValidateFunc: validation.StringInSlice([]string{"ALL", "IP", "HTTP_HEADER", "XFF_IP"}, false), - Description: `Determines the key to enforce the rateLimitThreshold on. Possible values are: "ALL" -- A single rate limit threshold is applied to all the requests matching this rule. This is the default value if this field 'enforceOnKey' is not configured. "IP" -- The source IP address of the request is the key. Each IP has this limit enforced separately. "HTTP_HEADER" -- The value of the HTTP Header whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the Header value. If no such header is present in the request, the key type defaults to "ALL". "XFF_IP" -- The first IP address (i.e. the originating client IP address) specified in the list of IPs under X-Forwarded-For HTTP Header. If no such header is present or the value is not a valid IP, the key type defaults to "ALL".`, + Type: schema.TypeString, + Optional: true, + Default: "ALL", + Description: `Determines the key to enforce the rateLimitThreshold on`, }, "enforce_on_key_name": { Type: schema.TypeString, Optional: true, - Description: `Rate limit key name applicable only for the following key types: HTTP_HEADER -- Name of the HTTP Header whose value is taken as the key value.`, + Description: `Rate limit key name applicable only for the following key types: HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value.`, }, "ban_threshold": { diff --git a/website/docs/r/compute_security_policy.html.markdown b/website/docs/r/compute_security_policy.html.markdown index 6f039d16f2..f91b32a815 100644 --- a/website/docs/r/compute_security_policy.html.markdown +++ b/website/docs/r/compute_security_policy.html.markdown @@ -69,10 +69,11 @@ The following arguments are supported: The `rule` block supports: * `action` - (Required) Action to take when `match` matches the request. Valid values: - * "allow" : allow access to target - * "deny(status)" : deny access to target, returns the HTTP response code specified (valid values are 403, 404 and 502) - * "rate_based_ban" : limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set. - * "threshold" : limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this. + * allow: allow access to target. + * deny(): deny access to target, returns the HTTP response code specified (valid values are 403, 404, and 502). + * rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set. + * redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions. + * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this. * `priority` - (Required) An unique positive integer indicating the priority of evaluation for a rule. Rules are evaluated from highest priority (lowest numerically) to lowest priority (highest numerically) in order. @@ -124,10 +125,15 @@ The following arguments are supported: * `conform_action` - (Optional) Action to take for requests that are under the configured rate limit threshold. Valid option is "allow" only. -* `enforce_on_key` - (Optional) Determines the key to enforce the rate_limit_threshold on. - Possible values incude "ALL", "ALL_IPS", "HTTP_HEADER", "IP", "XFF_IP". If not specified, defaults to "ALL". +* `enforce_on_key` - (Optional) Determines the key to enforce the rate_limit_threshold on. If not specified, defaults to "ALL". -* `enforce_on_key_name` - (Optional) Rate limit key name applicable only for HTTP_HEADER key types. Name of the HTTP header whose value is taken as the key value. + * ALL: A single rate limit threshold is applied to all the requests matching this rule. + * IP: The source IP address of the request is the key. Each IP has this limit enforced separately. + * HTTP_HEADER: The value of the HTTP header whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the header value. If no such header is present in the request, the key type defaults to ALL. + * XFF_IP: The first IP address (i.e. the originating client IP address) specified in the list of IPs under X-Forwarded-For HTTP header. If no such header is present or the value is not a valid IP, the key type defaults to ALL. + * HTTP_COOKIE: The value of the HTTP cookie whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the cookie value. If no such cookie is present in the request, the key type defaults to ALL. + +* `enforce_on_key_name` - (Optional) Rate limit key name applicable only for the following key types: HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value. * `exceed_action` - (Optional) When a request is denied, returns the HTTP response code specified. Valid options are "deny()" where valid values for status are 403, 404, 429, and 502.