diff --git a/.changelog/11360.txt b/.changelog/11360.txt
new file mode 100644
index 00000000000..25732b18372
--- /dev/null
+++ b/.changelog/11360.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+compute: `google_compute_firewall_policy_rule` now uses MMv1 engine instead of DCL.
+```
\ No newline at end of file
diff --git a/google/services/compute/resource_compute_firewall_policy_rule_test.go b/google/services/compute/resource_compute_firewall_policy_rule_test.go
index 3e36b5206b1..1cd7a4dd50f 100644
--- a/google/services/compute/resource_compute_firewall_policy_rule_test.go
+++ b/google/services/compute/resource_compute_firewall_policy_rule_test.go
@@ -149,6 +149,81 @@ func TestAccComputeFirewallPolicyRule_securityProfileGroup_update(t *testing.T)
})
}
+func TestAccComputeFirewallPolicyRule_basic(t *testing.T) {
+ t.Parallel()
+
+ context := map[string]interface{}{
+ "random_suffix": acctest.RandString(t, 10),
+ "org_name": fmt.Sprintf("organizations/%s", envvar.GetTestOrgFromEnv(t)),
+ }
+
+ acctest.VcrTest(t, resource.TestCase{
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccComputeFirewallPolicyRule_basic(context),
+ },
+ {
+ ResourceName: "google_compute_firewall_policy_rule.fw_policy_rule",
+ ImportState: true,
+ ImportStateVerify: true,
+ // Referencing using ID causes import to fail
+ ImportStateVerifyIgnore: []string{"firewall_policy"},
+ },
+ },
+ })
+}
+
+func testAccComputeFirewallPolicyRule_basic(context map[string]interface{}) string {
+ return acctest.Nprintf(`
+resource "google_folder" "folder" {
+ display_name = "tf-test-folder-%{random_suffix}"
+ parent = "%{org_name}"
+ deletion_protection = false
+}
+
+resource "google_compute_firewall_policy" "fw_policy" {
+ parent = google_folder.folder.name
+ short_name = "tf-test-policy-%{random_suffix}"
+ description = "Resource created for Terraform acceptance testing"
+}
+
+resource "google_network_security_address_group" "address_group" {
+ name = "tf-test-policy-%{random_suffix}"
+ parent = "%{org_name}"
+ description = "Sample global networksecurity_address_group"
+ location = "global"
+ items = ["208.80.154.224/32"]
+ type = "IPV4"
+ capacity = 100
+}
+
+resource "google_compute_firewall_policy_rule" "fw_policy_rule" {
+ firewall_policy = google_compute_firewall_policy.fw_policy.id
+ description = "Resource created for Terraform acceptance testing"
+ priority = 9000
+ enable_logging = true
+ action = "allow"
+ direction = "EGRESS"
+ disabled = false
+ tls_inspect = false
+
+ match {
+ layer4_configs {
+ ip_protocol = "tcp"
+ ports = [80, 8080]
+ }
+ dest_ip_ranges = ["11.100.0.1/32"]
+ dest_fqdns = ["google.com"]
+ dest_region_codes = ["US"]
+ dest_threat_intelligences = ["iplist-known-malicious-ips"]
+ dest_address_groups = [google_network_security_address_group.address_group.id]
+ }
+}
+`, context)
+}
+
func testAccComputeFirewallPolicyRule_securityProfileGroup_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_folder" "folder" {
@@ -366,13 +441,14 @@ resource "google_network_security_address_group" "address_group" {
}
resource "google_compute_firewall_policy_rule" "fw_policy_rule1" {
- firewall_policy = google_compute_firewall_policy.fw_policy.id
- description = "Resource created for Terraform acceptance testing"
- priority = 9000
- enable_logging = true
- action = "allow"
- direction = "EGRESS"
- disabled = false
+ firewall_policy = google_compute_firewall_policy.fw_policy.id
+ description = "Resource created for Terraform acceptance testing"
+ priority = 9000
+ enable_logging = true
+ action = "allow"
+ direction = "EGRESS"
+ disabled = false
+
target_service_accounts = [google_service_account.service_account.email]
target_resources = [
google_compute_network.network1.self_link,
@@ -442,13 +518,14 @@ resource "google_network_security_address_group" "address_group" {
}
resource "google_compute_firewall_policy_rule" "fw_policy_rule1" {
- firewall_policy = google_compute_firewall_policy.fw_policy.id
- description = "Test description"
- priority = 9000
- enable_logging = false
- action = "deny"
- direction = "INGRESS"
- disabled = true
+ firewall_policy = google_compute_firewall_policy.fw_policy.id
+ description = "Test description"
+ priority = 9000
+ enable_logging = false
+ action = "deny"
+ direction = "INGRESS"
+ disabled = false
+
target_resources = [google_compute_network.network1.self_link]
target_service_accounts = [
google_service_account.service_account.email,
diff --git a/website/docs/r/compute_firewall_policy_rule.html.markdown b/website/docs/r/compute_firewall_policy_rule.html.markdown
index ba83b035d7c..e71da9cf0ad 100644
--- a/website/docs/r/compute_firewall_policy_rule.html.markdown
+++ b/website/docs/r/compute_firewall_policy_rule.html.markdown
@@ -1,31 +1,41 @@
---
# ----------------------------------------------------------------------------
#
-# *** AUTO GENERATED CODE *** Type: DCL ***
+# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
-# This file is managed by Magic Modules (https:#github.com/GoogleCloudPlatform/magic-modules)
-# and is based on the DCL (https:#github.com/GoogleCloudPlatform/declarative-resource-client-library).
-# Changes will need to be made to the DCL or Magic Modules instead of here.
+# This file is automatically generated by Magic Modules and manual
+# changes will be clobbered when the file is regenerated.
#
-# We are not currently able to accept contributions to this file. If changes
-# are required, please file an issue at https:#github.com/hashicorp/terraform-provider-google/issues/new/choose
+# Please read more about how to change this file in
+# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Compute Engine"
description: |-
- The Compute FirewallPolicyRule resource
+ Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny).
---
# google_compute_firewall_policy_rule
-The Compute FirewallPolicyRule resource
+Represents a rule that describes one or more match conditions along with the action to be taken when traffic matches this condition (allow or deny).
+
+~> **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 FirewallPolicyRule, see:
+
+* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/firewallPolicies/addRule)
+
+## Example Usage - Firewall Policy Rule
+
-## Example Usage - basic_fir_sec_rule
```hcl
resource "google_network_security_address_group" "basic_global_networksecurity_address_group" {
- name = "policy"
+ provider = google-beta
+
+ name = "address"
parent = "organizations/123456789"
description = "Sample global networksecurity_address_group"
location = "global"
@@ -35,18 +45,24 @@ resource "google_network_security_address_group" "basic_global_networksecurity_a
}
resource "google_folder" "folder" {
- display_name = "policy"
- parent = "organizations/123456789"
+ provider = google-beta
+
+ display_name = "folder"
+ parent = "organizations/123456789"
deletion_protection = false
}
resource "google_compute_firewall_policy" "default" {
+ provider = google-beta
+
parent = google_folder.folder.id
short_name = "policy"
description = "Resource created for Terraform acceptance testing"
}
-resource "google_compute_firewall_policy_rule" "primary" {
+resource "google_compute_firewall_policy_rule" "policy_rule" {
+ provider = google-beta
+
firewall_policy = google_compute_firewall_policy.default.name
description = "Resource created for Terraform acceptance testing"
priority = 9000
@@ -54,6 +70,7 @@ resource "google_compute_firewall_policy_rule" "primary" {
action = "allow"
direction = "EGRESS"
disabled = false
+
match {
layer4_configs {
ip_protocol = "tcp"
@@ -72,121 +89,138 @@ resource "google_compute_firewall_policy_rule" "primary" {
}
target_service_accounts = ["my@service-account.com"]
}
-
```
## 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 prority.
+
+* `match` -
+ (Required)
+ 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).
+
* `action` -
(Required)
The Action to perform when the client connection triggers the rule. Valid actions are "allow", "deny", "goto_next" and "apply_security_profile_group".
-
+
* `direction` -
(Required)
- The direction in which this rule applies. Possible values: INGRESS, EGRESS
-
+ The direction in which this rule applies.
+ Possible values are: `INGRESS`, `EGRESS`.
+
* `firewall_policy` -
(Required)
The firewall policy of the resource.
-
-* `match` -
- (Required)
- A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding 'action' is enforced.
-
-* `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 prority.
-
-The `match` block supports:
-
-* `dest_address_groups` -
- (Optional)
- Address groups which should be matched against the traffic destination. Maximum number of destination address groups is 10. Destination address groups is only supported in Egress rules.
-
-* `dest_fqdns` -
+The `match` block supports:
+
+* `src_ip_ranges` -
(Optional)
- Domain names that will be used to match against the resolved domain name of destination of traffic. Can only be specified if DIRECTION is egress.
-
+ CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 5000.
+
* `dest_ip_ranges` -
(Optional)
- CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 256.
-
-* `dest_region_codes` -
- (Optional)
- The Unicode country codes whose IP addresses will be used to match against the source of traffic. Can only be specified if DIRECTION is egress.
-
-* `dest_threat_intelligences` -
- (Optional)
- Name of the Google Cloud Threat Intelligence list.
-
+ CIDR IP address range. Maximum number of destination CIDR IP ranges allowed is 5000.
+
* `layer4_configs` -
(Required)
Pairs of IP protocols and ports that the rule should match.
-
+ Structure is [documented below](#nested_layer4_configs).
+
+* `dest_address_groups` -
+ (Optional)
+ Address groups which should be matched against the traffic destination. Maximum number of destination address groups is 10.
+
* `src_address_groups` -
(Optional)
- Address groups which should be matched against the traffic source. Maximum number of source address groups is 10. Source address groups is only supported in Ingress rules.
-
+ Address groups which should be matched against the traffic source. Maximum number of source address groups is 10.
+
* `src_fqdns` -
(Optional)
- Domain names that will be used to match against the resolved domain name of source of traffic. Can only be specified if DIRECTION is ingress.
-
-* `src_ip_ranges` -
+ Fully Qualified Domain Name (FQDN) which should be matched against traffic source. Maximum number of source fqdn allowed is 100.
+
+* `dest_fqdns` -
(Optional)
- CIDR IP address range. Maximum number of source CIDR IP ranges allowed is 256.
-
+ Fully Qualified Domain Name (FQDN) which should be matched against traffic destination. Maximum number of destination fqdn allowed is 100.
+
* `src_region_codes` -
(Optional)
- The Unicode country codes whose IP addresses will be used to match against the source of traffic. Can only be specified if DIRECTION is ingress.
-
+ Region codes whose IP addresses will be used to match for source of traffic. Should be specified as 2 letter country code defined as per ISO 3166 alpha-2 country codes. ex."US" Maximum number of source region codes allowed is 5000.
+
+* `dest_region_codes` -
+ (Optional)
+ Region codes whose IP addresses will be used to match for destination of traffic. Should be specified as 2 letter country code defined as per ISO 3166 alpha-2 country codes. ex."US" Maximum number of dest region codes allowed is 5000.
+
+* `dest_threat_intelligences` -
+ (Optional)
+ Names of Network Threat Intelligence lists. The IPs in these lists will be matched against traffic destination.
+
* `src_threat_intelligences` -
(Optional)
- Name of the Google Cloud Threat Intelligence list.
-
-The `layer4_configs` block supports:
-
+ Names of Network Threat Intelligence lists. The IPs in these lists will be matched against traffic source.
+
+
+The `layer4_configs` block supports:
+
* `ip_protocol` -
(Required)
- The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule. This value can either be one of the following well known protocol strings (`tcp`, `udp`, `icmp`, `esp`, `ah`, `ipip`, `sctp`), or the IP protocol number.
-
+ The IP protocol to which this rule applies. The protocol type is required when creating a firewall rule.
+ This value can either be one of the following well known protocol strings (tcp, udp, icmp, esp, ah, ipip, sctp), or the IP protocol number.
+
* `ports` -
(Optional)
- An optional list of ports to which this rule applies. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port. Example inputs include: ``.
-
+ An optional list of ports to which this rule applies. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, this rule applies to connections through any port.
+ Example inputs include: ["22"], ["80","443"], and ["12345-12349"].
+
- - -
+
* `description` -
(Optional)
An optional description for this resource.
-
-* `disabled` -
- (Optional)
- Denotes whether the firewall policy rule is disabled. When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist. If this is unspecified, the firewall policy rule will be enabled.
-
-* `enable_logging` -
- (Optional)
- Denotes whether to enable logging for a particular rule. If logging is enabled, logs will be exported to the configured export destination in Stackdriver. Logs may be exported to BigQuery or Pub/Sub. Note: you cannot enable logging on "goto_next" rules.
-
+
* `security_profile_group` -
(Optional)
- A fully-qualified URL of a SecurityProfileGroup resource. Example: https://networksecurity.googleapis.com/v1/organizations/{organizationId}/locations/global/securityProfileGroups/my-security-profile-group. It must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.
-
+ A fully-qualified URL of a SecurityProfile resource instance.
+ Example: https://networksecurity.googleapis.com/v1/projects/{project}/locations/{location}/securityProfileGroups/my-security-profile-group
+ Must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.
+
+* `tls_inspect` -
+ (Optional)
+ Boolean flag indicating if the traffic should be TLS decrypted.
+ Can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.
+
* `target_resources` -
(Optional)
- A list of network resource URLs to which this rule applies. This field allows you to control which network's VMs get this rule. If this field is left blank, all VMs within the organization will receive the rule.
-
+ A list of network resource URLs to which this rule applies.
+ This field allows you to control which network's VMs get this rule.
+ If this field is left blank, all VMs within the organization will receive the rule.
+
+* `enable_logging` -
+ (Optional)
+ Denotes whether to enable logging for a particular rule.
+ If logging is enabled, logs will be exported to the configured export destination in Stackdriver.
+ Logs may be exported to BigQuery or Pub/Sub.
+ Note: you cannot enable logging on "goto_next" rules.
+
* `target_service_accounts` -
(Optional)
A list of service accounts indicating the sets of instances that are applied with this rule.
-
-* `tls_inspect` -
+
+* `disabled` -
(Optional)
- Boolean flag indicating if the traffic should be TLS decrypted. It can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.
-
+ Denotes whether the firewall policy rule is disabled.
+ When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist.
+ If this is unspecified, the firewall policy rule will be enabled.
## Attributes Reference
@@ -195,12 +229,16 @@ In addition to the arguments listed above, the following computed attributes are
* `id` - an identifier for the resource with format `locations/global/firewallPolicies/{{firewall_policy}}/rules/{{priority}}`
+* `creation_timestamp` -
+ Creation timestamp in RFC3339 text format.
+
* `kind` -
Type of the resource. Always `compute#firewallPolicyRule` for firewall policy rules
-
+
* `rule_tuple_count` -
Calculation of the complexity of a single firewall policy rule.
-
+
+
## Timeouts
This resource provides the following
@@ -212,12 +250,14 @@ This resource provides the following
## Import
+
FirewallPolicyRule can be imported using any of these accepted formats:
+
* `locations/global/firewallPolicies/{{firewall_policy}}/rules/{{priority}}`
* `{{firewall_policy}}/{{priority}}`
-In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import FirewallPolicyRule using one of the formats above. For example:
+In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import FirewallPolicyRule using one of the formats above. For example:
```tf
import {
@@ -232,6 +272,3 @@ When using the [`terraform import` command](https://developer.hashicorp.com/terr
$ terraform import google_compute_firewall_policy_rule.default locations/global/firewallPolicies/{{firewall_policy}}/rules/{{priority}}
$ terraform import google_compute_firewall_policy_rule.default {{firewall_policy}}/{{priority}}
```
-
-
-