| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Compute Engine" |
| description: |- |
| A rule for the RegionSecurityPolicy. |
| --- |
| |
| # google_compute_region_security_policy_rule |
| |
| A rule for the RegionSecurityPolicy. |
| |
| ~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. |
| See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. |
| |
| To get more information about RegionSecurityPolicyRule, see: |
| |
| * [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/regionSecurityPolicies/addRule) |
| * How-to Guides |
| * [Creating region security policy rules](https://cloud.google.com/armor/docs/configure-security-policies) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=region_security_policy_rule_basic&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Region Security Policy Rule Basic |
| |
| |
| ```hcl |
| resource "google_compute_region_security_policy" "default" { |
| provider = google-beta |
| |
| region = "us-west2" |
| name = "policyruletest" |
| description = "basic region security policy" |
| type = "CLOUD_ARMOR" |
| } |
| |
| resource "google_compute_region_security_policy_rule" "policy_rule" { |
| provider = google-beta |
| |
| region = "us-west2" |
| security_policy = google_compute_region_security_policy.default.name |
| description = "new rule" |
| priority = 100 |
| match { |
| versioned_expr = "SRC_IPS_V1" |
| config { |
| src_ip_ranges = ["10.10.0.0/16"] |
| } |
| } |
| action = "allow" |
| preview = true |
| } |
| ``` |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=region_security_policy_rule_multiple_rules&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Region Security Policy Rule Multiple Rules |
| |
| |
| ```hcl |
| resource "google_compute_region_security_policy" "default" { |
| provider = google-beta |
| |
| region = "us-west2" |
| name = "policywithmultiplerules" |
| description = "basic region security policy" |
| type = "CLOUD_ARMOR" |
| } |
| |
| resource "google_compute_region_security_policy_rule" "policy_rule_one" { |
| provider = google-beta |
| |
| region = "us-west2" |
| security_policy = google_compute_region_security_policy.default.name |
| description = "new rule one" |
| priority = 100 |
| match { |
| versioned_expr = "SRC_IPS_V1" |
| config { |
| src_ip_ranges = ["10.10.0.0/16"] |
| } |
| } |
| action = "allow" |
| preview = true |
| } |
| |
| resource "google_compute_region_security_policy_rule" "policy_rule_two" { |
| provider = google-beta |
| |
| region = "us-west2" |
| security_policy = google_compute_region_security_policy.default.name |
| description = "new rule two" |
| priority = 101 |
| match { |
| versioned_expr = "SRC_IPS_V1" |
| config { |
| src_ip_ranges = ["192.168.0.0/16", "10.0.0.0/8"] |
| } |
| } |
| action = "allow" |
| preview = true |
| } |
| ``` |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=region_security_policy_rule_with_preconfigured_waf_config&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Region Security Policy Rule With Preconfigured Waf Config |
| |
| |
| ```hcl |
| resource "google_compute_region_security_policy" "default" { |
| provider = google-beta |
| |
| region = "asia-southeast1" |
| name = "policyruletest" |
| description = "basic region security policy" |
| type = "CLOUD_ARMOR" |
| } |
| |
| resource "google_compute_region_security_policy_rule" "policy_rule" { |
| provider = google-beta |
| |
| region = "asia-southeast1" |
| security_policy = google_compute_region_security_policy.default.name |
| description = "new rule" |
| priority = 100 |
| match { |
| versioned_expr = "SRC_IPS_V1" |
| config { |
| src_ip_ranges = ["10.10.0.0/16"] |
| } |
| } |
| preconfigured_waf_config { |
| exclusion { |
| request_uri { |
| operator = "STARTS_WITH" |
| value = "/admin" |
| } |
| target_rule_set = "rce-stable" |
| } |
| exclusion { |
| request_query_param { |
| operator = "CONTAINS" |
| value = "password" |
| } |
| request_query_param { |
| operator = "STARTS_WITH" |
| value = "freeform" |
| } |
| request_query_param { |
| operator = "EQUALS" |
| value = "description" |
| } |
| target_rule_set = "xss-stable" |
| target_rule_ids = [ |
| "owasp-crs-v030001-id941330-xss", |
| "owasp-crs-v030001-id941340-xss", |
| ] |
| } |
| } |
| action = "allow" |
| preview = true |
| } |
| ``` |
| ## Example Usage - Region Security Policy Rule With Network Match |
| |
| |
| ```hcl |
| # First activate advanced network DDoS protection for the desired region |
| resource "google_compute_region_security_policy" "policyddosprotection" { |
| provider = google-beta |
| |
| region = "us-west2" |
| name = "policyddosprotection" |
| description = "policy for activating network DDoS protection for the desired region" |
| type = "CLOUD_ARMOR_NETWORK" |
| ddos_protection_config { |
| ddos_protection = "ADVANCED_PREVIEW" |
| } |
| } |
| |
| resource "google_compute_network_edge_security_service" "edge_sec_service" { |
| provider = google-beta |
| |
| region = "us-west2" |
| name = "edgesecservice" |
| description = "linking policy to edge security service" |
| security_policy = google_compute_region_security_policy.policyddosprotection.self_link |
| } |
| |
| # Add the desired policy and custom rule. |
| resource "google_compute_region_security_policy" "policynetworkmatch" { |
| provider = google-beta |
| |
| region = "us-west2" |
| name = "policyfornetworkmatch" |
| description = "region security policy for network match" |
| type = "CLOUD_ARMOR_NETWORK" |
| user_defined_fields { |
| name = "SIG1_AT_0" |
| base = "TCP" |
| offset = 8 |
| size = 2 |
| mask = "0x8F00" |
| } |
| depends_on = [google_compute_network_edge_security_service.edge_sec_service] |
| } |
| |
| resource "google_compute_region_security_policy_rule" "policy_rule_network_match" { |
| provider = google-beta |
| |
| region = "us-west2" |
| security_policy = google_compute_region_security_policy.policynetworkmatch.name |
| description = "custom rule for network match" |
| priority = 100 |
| network_match { |
| src_ip_ranges = ["10.10.0.0/16"] |
| user_defined_fields { |
| name = "SIG1_AT_0" |
| values = ["0x8F00"] |
| } |
| } |
| action = "allow" |
| preview = true |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `priority` - |
| (Required) |
| An integer indicating the priority of a rule in the list. |
| The priority must be a positive value between 0 and 2147483647. |
| Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest priority. |
| |
| * `action` - |
| (Required) |
| The Action to perform when the rule is matched. The following are the valid actions: |
| * allow: allow access to target. |
| * deny(STATUS): deny access to target, returns the HTTP response code specified. Valid values for STATUS 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. This action is only supported in Global Security Policies of type CLOUD_ARMOR. |
| * throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this. |
| |
| * `region` - |
| (Required) |
| The Region in which the created Region Security Policy rule should reside. |
| |
| * `security_policy` - |
| (Required) |
| The name of the security policy this rule belongs to. |
| |
| |
| - - - |
| |
| |
| * `description` - |
| (Optional) |
| An optional description of this resource. Provide this property when you create the resource. |
| |
| * `match` - |
| (Optional) |
| A match condition that incoming traffic is evaluated against. |
| If it evaluates to true, the corresponding 'action' is enforced. |
| Structure is [documented below](#nested_match). |
| |
| * `preconfigured_waf_config` - |
| (Optional) |
| Preconfigured WAF configuration to be applied for the rule. |
| If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect. |
| Structure is [documented below](#nested_preconfigured_waf_config). |
| |
| * `rate_limit_options` - |
| (Optional) |
| Must be specified if the action is "rate_based_ban" or "throttle". Cannot be specified for any other actions. |
| Structure is [documented below](#nested_rate_limit_options). |
| |
| * `preview` - |
| (Optional) |
| If set to true, the specified action is not enforced. |
| |
| * `network_match` - |
| (Optional) |
| A match condition that incoming packets are evaluated against for CLOUD_ARMOR_NETWORK security policies. If it matches, the corresponding 'action' is enforced. |
| The match criteria for a rule consists of built-in match fields (like 'srcIpRanges') and potentially multiple user-defined match fields ('userDefinedFields'). |
| Field values may be extracted directly from the packet or derived from it (e.g. 'srcRegionCodes'). Some fields may not be present in every packet (e.g. 'srcPorts'). A user-defined field is only present if the base header is found in the packet and the entire field is in bounds. |
| Each match field may specify which values can match it, listing one or more ranges, prefixes, or exact values that are considered a match for the field. A field value must be present in order to match a specified match field. If no match values are specified for a match field, then any field value is considered to match it, and it's not required to be present. For strings specifying '*' is also equivalent to match all. |
| For a packet to match a rule, all specified match fields must match the corresponding field values derived from the packet. |
| Example: |
| networkMatch: srcIpRanges: - "192.0.2.0/24" - "198.51.100.0/24" userDefinedFields: - name: "ipv4_fragment_offset" values: - "1-0x1fff" |
| The above match condition matches packets with a source IP in 192.0.2.0/24 or 198.51.100.0/24 and a user-defined field named "ipv4_fragment_offset" with a value between 1 and 0x1fff inclusive |
| Structure is [documented below](#nested_network_match). |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| |
| <a name="nested_match"></a>The `match` block supports: |
| |
| * `versioned_expr` - |
| (Optional) |
| Preconfigured versioned expression. If this field is specified, config must also be specified. |
| Available preconfigured expressions along with their requirements are: SRC_IPS_V1 - must specify the corresponding srcIpRange field in config. |
| Possible values are: `SRC_IPS_V1`. |
| |
| * `expr` - |
| (Optional) |
| User defined CEVAL expression. A CEVAL expression is used to specify match criteria such as origin.ip, source.region_code and contents in the request header. |
| Structure is [documented below](#nested_expr). |
| |
| * `config` - |
| (Optional) |
| The configuration options available when specifying versionedExpr. |
| This field must be specified if versionedExpr is specified and cannot be specified if versionedExpr is not specified. |
| Structure is [documented below](#nested_config). |
| |
| |
| <a name="nested_expr"></a>The `expr` block supports: |
| |
| * `expression` - |
| (Required) |
| Textual representation of an expression in Common Expression Language syntax. The application context of the containing message determines which well-known feature set of CEL is supported. |
| |
| <a name="nested_config"></a>The `config` block supports: |
| |
| * `src_ip_ranges` - |
| (Optional) |
| CIDR IP address range. Maximum number of srcIpRanges allowed is 10. |
| |
| <a name="nested_preconfigured_waf_config"></a>The `preconfigured_waf_config` block supports: |
| |
| * `exclusion` - |
| (Optional) |
| An exclusion to apply during preconfigured WAF evaluation. |
| Structure is [documented below](#nested_exclusion). |
| |
| |
| <a name="nested_exclusion"></a>The `exclusion` block supports: |
| |
| * `target_rule_set` - |
| (Required) |
| Target WAF rule set to apply the preconfigured WAF exclusion. |
| |
| * `target_rule_ids` - |
| (Optional) |
| A list of target rule IDs under the WAF rule set to apply the preconfigured WAF exclusion. |
| If omitted, it refers to all the rule IDs under the WAF rule set. |
| |
| * `request_header` - |
| (Optional) |
| Request header whose value will be excluded from inspection during preconfigured WAF evaluation. |
| Structure is [documented below](#nested_request_header). |
| |
| * `request_cookie` - |
| (Optional) |
| Request cookie whose value will be excluded from inspection during preconfigured WAF evaluation. |
| Structure is [documented below](#nested_request_cookie). |
| |
| * `request_uri` - |
| (Optional) |
| Request URI from the request line to be excluded from inspection during preconfigured WAF evaluation. |
| When specifying this field, the query or fragment part should be excluded. |
| Structure is [documented below](#nested_request_uri). |
| |
| * `request_query_param` - |
| (Optional) |
| Request query parameter whose value will be excluded from inspection during preconfigured WAF evaluation. |
| Note that the parameter can be in the query string or in the POST body. |
| Structure is [documented below](#nested_request_query_param). |
| |
| |
| <a name="nested_request_header"></a>The `request_header` block supports: |
| |
| * `operator` - |
| (Required) |
| You can specify an exact match or a partial match by using a field operator and a field value. |
| Available options: |
| EQUALS: The operator matches if the field value equals the specified value. |
| STARTS_WITH: The operator matches if the field value starts with the specified value. |
| ENDS_WITH: The operator matches if the field value ends with the specified value. |
| CONTAINS: The operator matches if the field value contains the specified value. |
| EQUALS_ANY: The operator matches if the field value is any value. |
| Possible values are: `CONTAINS`, `ENDS_WITH`, `EQUALS`, `EQUALS_ANY`, `STARTS_WITH`. |
| |
| * `value` - |
| (Optional) |
| A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. |
| The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
| |
| <a name="nested_request_cookie"></a>The `request_cookie` block supports: |
| |
| * `operator` - |
| (Required) |
| You can specify an exact match or a partial match by using a field operator and a field value. |
| Available options: |
| EQUALS: The operator matches if the field value equals the specified value. |
| STARTS_WITH: The operator matches if the field value starts with the specified value. |
| ENDS_WITH: The operator matches if the field value ends with the specified value. |
| CONTAINS: The operator matches if the field value contains the specified value. |
| EQUALS_ANY: The operator matches if the field value is any value. |
| Possible values are: `CONTAINS`, `ENDS_WITH`, `EQUALS`, `EQUALS_ANY`, `STARTS_WITH`. |
| |
| * `value` - |
| (Optional) |
| A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. |
| The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
| |
| <a name="nested_request_uri"></a>The `request_uri` block supports: |
| |
| * `operator` - |
| (Required) |
| You can specify an exact match or a partial match by using a field operator and a field value. |
| Available options: |
| EQUALS: The operator matches if the field value equals the specified value. |
| STARTS_WITH: The operator matches if the field value starts with the specified value. |
| ENDS_WITH: The operator matches if the field value ends with the specified value. |
| CONTAINS: The operator matches if the field value contains the specified value. |
| EQUALS_ANY: The operator matches if the field value is any value. |
| Possible values are: `CONTAINS`, `ENDS_WITH`, `EQUALS`, `EQUALS_ANY`, `STARTS_WITH`. |
| |
| * `value` - |
| (Optional) |
| A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. |
| The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
| |
| <a name="nested_request_query_param"></a>The `request_query_param` block supports: |
| |
| * `operator` - |
| (Required) |
| You can specify an exact match or a partial match by using a field operator and a field value. |
| Available options: |
| EQUALS: The operator matches if the field value equals the specified value. |
| STARTS_WITH: The operator matches if the field value starts with the specified value. |
| ENDS_WITH: The operator matches if the field value ends with the specified value. |
| CONTAINS: The operator matches if the field value contains the specified value. |
| EQUALS_ANY: The operator matches if the field value is any value. |
| Possible values are: `CONTAINS`, `ENDS_WITH`, `EQUALS`, `EQUALS_ANY`, `STARTS_WITH`. |
| |
| * `value` - |
| (Optional) |
| A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. |
| The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY. |
| |
| <a name="nested_rate_limit_options"></a>The `rate_limit_options` block supports: |
| |
| * `rate_limit_threshold` - |
| (Optional) |
| Threshold at which to begin ratelimiting. |
| Structure is [documented below](#nested_rate_limit_threshold). |
| |
| * `conform_action` - |
| (Optional) |
| Action to take for requests that are under the configured rate limit threshold. |
| Valid option is "allow" only. |
| |
| * `exceed_action` - |
| (Optional) |
| Action to take for requests that are above the configured rate limit threshold, to deny with a specified HTTP response code. |
| Valid options are deny(STATUS), where valid values for STATUS are 403, 404, 429, and 502. |
| |
| * `enforce_on_key` - |
| (Optional) |
| 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 "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 defaults to the source IP address of the request i.e. key type IP. |
| * 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. |
| * HTTP_PATH: The URL path of the HTTP request. The key value is truncated to the first 128 bytes. |
| * SNI: Server name indication in the TLS session of the HTTPS request. The key value is truncated to the first 128 bytes. The key type defaults to ALL on a HTTP session. |
| * REGION_CODE: The country/region from which the request originates. |
| * TLS_JA3_FINGERPRINT: JA3 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or HTTP/3. If not available, the key type defaults to ALL. |
| * USER_IP: The IP address of the originating client, which is resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, the key type defaults to IP. |
| Possible values are: `ALL`, `IP`, `HTTP_HEADER`, `XFF_IP`, `HTTP_COOKIE`, `HTTP_PATH`, `SNI`, `REGION_CODE`, `TLS_JA3_FINGERPRINT`, `USER_IP`. |
| |
| * `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. |
| |
| * `enforce_on_key_configs` - |
| (Optional) |
| If specified, any combination of values of enforceOnKeyType/enforceOnKeyName is treated as the key on which ratelimit threshold/action is enforced. |
| You can specify up to 3 enforceOnKeyConfigs. |
| If enforceOnKeyConfigs is specified, enforceOnKey must not be specified. |
| Structure is [documented below](#nested_enforce_on_key_configs). |
| |
| * `ban_threshold` - |
| (Optional) |
| Can only be specified if the action for the rule is "rate_based_ban". |
| If specified, the key will be banned for the configured 'banDurationSec' when the number of requests that exceed the 'rateLimitThreshold' also exceed this 'banThreshold'. |
| Structure is [documented below](#nested_ban_threshold). |
| |
| * `ban_duration_sec` - |
| (Optional) |
| Can only be specified if the action for the rule is "rate_based_ban". |
| If specified, determines the time (in seconds) the traffic will continue to be banned by the rate limit after the rate falls below the threshold. |
| |
| |
| <a name="nested_rate_limit_threshold"></a>The `rate_limit_threshold` block supports: |
| |
| * `count` - |
| (Optional) |
| Number of HTTP(S) requests for calculating the threshold. |
| |
| * `interval_sec` - |
| (Optional) |
| Interval over which the threshold is computed. |
| |
| <a name="nested_enforce_on_key_configs"></a>The `enforce_on_key_configs` block supports: |
| |
| * `enforce_on_key_type` - |
| (Optional) |
| 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 "enforceOnKeyConfigs" 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 defaults to the source IP address of the request i.e. key type IP. |
| * 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. |
| * HTTP_PATH: The URL path of the HTTP request. The key value is truncated to the first 128 bytes. |
| * SNI: Server name indication in the TLS session of the HTTPS request. The key value is truncated to the first 128 bytes. The key type defaults to ALL on a HTTP session. |
| * REGION_CODE: The country/region from which the request originates. |
| * TLS_JA3_FINGERPRINT: JA3 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or HTTP/3. If not available, the key type defaults to ALL. |
| * USER_IP: The IP address of the originating client, which is resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, the key type defaults to IP. |
| Possible values are: `ALL`, `IP`, `HTTP_HEADER`, `XFF_IP`, `HTTP_COOKIE`, `HTTP_PATH`, `SNI`, `REGION_CODE`, `TLS_JA3_FINGERPRINT`, `USER_IP`. |
| |
| * `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. |
| |
| <a name="nested_ban_threshold"></a>The `ban_threshold` block supports: |
| |
| * `count` - |
| (Optional) |
| Number of HTTP(S) requests for calculating the threshold. |
| |
| * `interval_sec` - |
| (Optional) |
| Interval over which the threshold is computed. |
| |
| <a name="nested_network_match"></a>The `network_match` block supports: |
| |
| * `user_defined_fields` - |
| (Optional) |
| User-defined fields. Each element names a defined field and lists the matching values for that field. |
| Structure is [documented below](#nested_user_defined_fields). |
| |
| * `src_ip_ranges` - |
| (Optional) |
| Source IPv4/IPv6 addresses or CIDR prefixes, in standard text format. |
| |
| * `dest_ip_ranges` - |
| (Optional) |
| Destination IPv4/IPv6 addresses or CIDR prefixes, in standard text format. |
| |
| * `ip_protocols` - |
| (Optional) |
| IPv4 protocol / IPv6 next header (after extension headers). Each element can be an 8-bit unsigned decimal number (e.g. "6"), range (e.g. "253-254"), or one of the following protocol names: "tcp", "udp", "icmp", "esp", "ah", "ipip", or "sctp". |
| |
| * `src_ports` - |
| (Optional) |
| Source port numbers for TCP/UDP/SCTP. Each element can be a 16-bit unsigned decimal number (e.g. "80") or range (e.g. "0-1023"). |
| |
| * `dest_ports` - |
| (Optional) |
| Destination port numbers for TCP/UDP/SCTP. Each element can be a 16-bit unsigned decimal number (e.g. "80") or range (e.g. "0-1023"). |
| |
| * `src_region_codes` - |
| (Optional) |
| Two-letter ISO 3166-1 alpha-2 country code associated with the source IP address. |
| |
| * `src_asns` - |
| (Optional) |
| BGP Autonomous System Number associated with the source IP address. |
| |
| |
| <a name="nested_user_defined_fields"></a>The `user_defined_fields` block supports: |
| |
| * `name` - |
| (Optional) |
| Name of the user-defined field, as given in the definition. |
| |
| * `values` - |
| (Optional) |
| Matching values of the field. Each element can be a 32-bit unsigned decimal or hexadecimal (starting with "0x") number (e.g. "64") or range (e.g. "0x400-0x7ff"). |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/securityPolicies/{{security_policy}}/priority/{{priority}}` |
| |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| RegionSecurityPolicyRule can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/regions/{{region}}/securityPolicies/{{security_policy}}/priority/{{priority}}` |
| * `{{project}}/{{region}}/{{security_policy}}/{{priority}}` |
| * `{{region}}/{{security_policy}}/{{priority}}` |
| * `{{security_policy}}/{{priority}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import RegionSecurityPolicyRule using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/regions/{{region}}/securityPolicies/{{security_policy}}/priority/{{priority}}" |
| to = google_compute_region_security_policy_rule.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), RegionSecurityPolicyRule can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_compute_region_security_policy_rule.default projects/{{project}}/regions/{{region}}/securityPolicies/{{security_policy}}/priority/{{priority}} |
| $ terraform import google_compute_region_security_policy_rule.default {{project}}/{{region}}/{{security_policy}}/{{priority}} |
| $ terraform import google_compute_region_security_policy_rule.default {{region}}/{{security_policy}}/{{priority}} |
| $ terraform import google_compute_region_security_policy_rule.default {{security_policy}}/{{priority}} |
| ``` |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |