Skip to content

Commit 536b55c

Browse files
authored
Fix google_compute_network_firewall_policy_rule staying disabled after apply with disabled = false (#15454)
1 parent 724a0dc commit 536b55c

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

mmv1/products/compute/NetworkFirewallPolicyRule.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ properties:
329329
- 'INEFFECTIVE'
330330
- name: 'disabled'
331331
type: Boolean
332+
send_empty_value: true
332333
description: |
333334
Denotes whether the firewall policy rule is disabled.
334335
When set to true, the firewall policy rule is not enforced and traffic behaves as if it did not exist.

mmv1/third_party/terraform/services/compute/resource_compute_network_firewall_policy_rule_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,42 @@ func TestAccComputeNetworkFirewallSecurityProfileGroupDiffsuppress(t *testing.T)
288288
})
289289
}
290290

291+
func TestAccComputeNetworkFirewallPolicyRule_disable_enable(t *testing.T) {
292+
t.Parallel()
293+
294+
context := map[string]interface{}{
295+
"random_suffix": acctest.RandString(t, 10),
296+
}
297+
298+
acctest.VcrTest(t, resource.TestCase{
299+
PreCheck: func() { acctest.AccTestPreCheck(t) },
300+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
301+
Steps: []resource.TestStep{
302+
{
303+
Config: testAccComputeNetworkFirewallPolicyRule_disabled(context, true),
304+
},
305+
{
306+
ResourceName: "google_compute_network_firewall_policy_rule.fw_policy_rule",
307+
ImportState: true,
308+
ImportStateVerify: true,
309+
ImportStateVerifyIgnore: []string{"firewall_policy"},
310+
},
311+
{
312+
Config: testAccComputeNetworkFirewallPolicyRule_disabled(context, false),
313+
Check: resource.ComposeTestCheckFunc(
314+
resource.TestCheckResourceAttr("google_compute_network_firewall_policy_rule.fw_policy_rule", "disabled", "false"),
315+
),
316+
},
317+
{
318+
ResourceName: "google_compute_network_firewall_policy_rule.fw_policy_rule",
319+
ImportState: true,
320+
ImportStateVerify: true,
321+
ImportStateVerifyIgnore: []string{"firewall_policy"},
322+
},
323+
},
324+
})
325+
}
326+
291327
func testAccComputeNetworkFirewallPolicyRule_secureTags(context map[string]interface{}) string {
292328
return acctest.Nprintf(`
293329
resource "google_network_security_address_group" "basic_global_networksecurity_address_group" {
@@ -1028,3 +1064,33 @@ resource "google_compute_network_firewall_policy_rule" "dest_test" {
10281064
10291065
`, context)
10301066
}
1067+
1068+
func testAccComputeNetworkFirewallPolicyRule_disabled(context map[string]interface{}, disabled bool) string {
1069+
context["disabled"] = fmt.Sprintf("%t", disabled)
1070+
return acctest.Nprintf(`
1071+
resource "google_compute_network" "network" {
1072+
name = "tf-test-%{random_suffix}"
1073+
auto_create_subnetworks = false
1074+
}
1075+
1076+
resource "google_compute_network_firewall_policy" "fw_policy" {
1077+
name = "tf-test-policy-%{random_suffix}"
1078+
}
1079+
1080+
resource "google_compute_network_firewall_policy_rule" "fw_policy_rule" {
1081+
firewall_policy = google_compute_network_firewall_policy.fw_policy.id
1082+
priority = 1000
1083+
action = "allow"
1084+
direction = "EGRESS"
1085+
disabled = %{disabled}
1086+
match {
1087+
dest_ip_ranges = ["35.235.240.0/20"]
1088+
1089+
layer4_configs {
1090+
ip_protocol = "tcp"
1091+
ports = [22]
1092+
}
1093+
}
1094+
}
1095+
`, context)
1096+
}

0 commit comments

Comments
 (0)