Skip to content

Commit a5418b4

Browse files
authored
fix: network-firewall-policy not able to use target_secure_tags (#514)
1 parent 4d93465 commit a5418b4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

modules/network-firewall-policy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ module "firewall_rules" {
135135
| policy\_name | User-provided name of the Network firewall policy | `string` | n/a | yes |
136136
| policy\_region | Location of the firewall policy. Needed for regional firewall policies. Default is null (Global firewall policy) | `string` | `null` | no |
137137
| project\_id | Project ID of the Network firewall policy | `string` | n/a | yes |
138-
| rules | List of Ingress/Egress rules | <pre>list(object({<br> priority = number<br> direction = string<br> action = string<br> rule_name = optional(string)<br> disabled = optional(bool)<br> description = optional(string)<br> enable_logging = optional(bool)<br> target_secure_tags = optional(list(string))<br> target_service_accounts = optional(list(string), [])<br> match = object({<br> src_ip_ranges = optional(list(string), [])<br> src_fqdns = optional(list(string), [])<br> src_region_codes = optional(list(string), [])<br> src_secure_tags = optional(list(string), [])<br> src_address_groups = optional(list(string), [])<br> dest_ip_ranges = optional(list(string), [])<br> dest_fqdns = optional(list(string), [])<br> dest_region_codes = optional(list(string), [])<br> dest_threat_intelligences = optional(list(string), [])<br> dest_address_groups = optional(list(string), [])<br> layer4_configs = optional(list(object({<br> ip_protocol = optional(string, "all")<br> ports = optional(list(string), [])<br> })), [{}])<br> })<br> }))</pre> | `[]` | no |
138+
| rules | List of Ingress/Egress rules | <pre>list(object({<br> priority = number<br> direction = string<br> action = string<br> rule_name = optional(string)<br> disabled = optional(bool)<br> description = optional(string)<br> enable_logging = optional(bool)<br> target_secure_tags = optional(list(string))<br> target_service_accounts = optional(list(string))<br> match = object({<br> src_ip_ranges = optional(list(string), [])<br> src_fqdns = optional(list(string), [])<br> src_region_codes = optional(list(string), [])<br> src_secure_tags = optional(list(string), [])<br> src_address_groups = optional(list(string), [])<br> dest_ip_ranges = optional(list(string), [])<br> dest_fqdns = optional(list(string), [])<br> dest_region_codes = optional(list(string), [])<br> dest_threat_intelligences = optional(list(string), [])<br> dest_address_groups = optional(list(string), [])<br> layer4_configs = optional(list(object({<br> ip_protocol = optional(string, "all")<br> ports = optional(list(string), [])<br> })), [{}])<br> })<br> }))</pre> | `[]` | no |
139139
| target\_vpcs | List of target VPC IDs that the firewall policy will be attached to | `list(string)` | `[]` | no |
140140

141141
## Outputs

modules/network-firewall-policy/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ variable "rules" {
5757
description = optional(string)
5858
enable_logging = optional(bool)
5959
target_secure_tags = optional(list(string))
60-
target_service_accounts = optional(list(string), [])
60+
target_service_accounts = optional(list(string))
6161
match = object({
6262
src_ip_ranges = optional(list(string), [])
6363
src_fqdns = optional(list(string), [])

test/integration/global-network-firewall-policy/global_firewall_policy_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func TestGlobalNetworkFirewallPolicy(t *testing.T) {
5555
assert.Equal("10.100.0.1/32", sp1.Get("match.srcIpRanges").Array()[0].String(), "has expected srcIpRanges")
5656
assert.Equal("US", sp1.Get("match.srcRegionCodes").Array()[0].String(), "has expected srcRegionCodes")
5757
assert.Equal("all", sp1.Get("match.layer4Configs").Array()[0].Get("ipProtocol").String(), "has expected layer4Configs.ipProtocol")
58-
secureTags := sp1.Get("match.srcSecureTags").Array()
59-
assert.Equal(1, len(secureTags), "should have the correct srcSecureTags count")
58+
secureTags1 := sp1.Get("match.srcSecureTags").Array()
59+
assert.Equal(1, len(secureTags1), "should have the correct srcSecureTags count - 1")
6060
srcAddressGroups := sp1.Get("match.srcAddressGroups").Array()
6161
assert.Equal(1, len(srcAddressGroups), "should have the correct srcAddressGroups count")
6262

@@ -72,6 +72,8 @@ func TestGlobalNetworkFirewallPolicy(t *testing.T) {
7272
assert.Equal("10.100.0.2/32", sp2.Get("match.srcIpRanges").Array()[0].String(), "has expected srcIpRanges")
7373
assert.Equal("BE", sp2.Get("match.srcRegionCodes").Array()[0].String(), "has expected srcRegionCodes")
7474
assert.Equal("all", sp2.Get("match.layer4Configs").Array()[0].Get("ipProtocol").String(), "has expected layer4Configs.ipProtocol")
75+
secureTags2 := sp2.Get("targetSecureTags").Array()
76+
assert.Equal(1, len(secureTags2), "should have the correct targetSecureTags count - 1")
7577

7678
rule3 := gcloud.Runf(t, "compute network-firewall-policies rules describe 3 --global-firewall-policy --firewall-policy %s --project %s", policyName, projectId)
7779
sp3 := rule3.Array()[0]
@@ -116,6 +118,8 @@ func TestGlobalNetworkFirewallPolicy(t *testing.T) {
116118
assert.Equal("10.100.0.2/32", sp102.Get("match.destIpRanges").Array()[0].String(), "has expected destIpRanges")
117119
assert.Equal("AR", sp102.Get("match.destRegionCodes").Array()[0].String(), "has expected destRegionCodes")
118120
assert.Equal("all", sp102.Get("match.layer4Configs").Array()[0].Get("ipProtocol").String(), "has expected layer4Configs.ipProtocol")
121+
secureTags102 := sp2.Get("targetSecureTags").Array()
122+
assert.Equal(1, len(secureTags102), "should have the correct targetSecureTags count - 1")
119123

120124
rule103 := gcloud.Runf(t, "compute network-firewall-policies rules describe 103 --global-firewall-policy --firewall-policy %s --project %s", policyName, projectId)
121125
sp103 := rule103.Array()[0]

0 commit comments

Comments
 (0)