@@ -142,6 +142,41 @@ func TestAccComputeNetworkFirewallPolicyRule_multipleRules(t *testing.T) {
142
142
})
143
143
}
144
144
145
+ func TestAccComputeNetworkFirewallPolicyRule_addressGroupOrder (t * testing.T ) {
146
+ t .Parallel ()
147
+
148
+ context := map [string ]interface {}{
149
+ "random_suffix" : acctest .RandString (t , 10 ),
150
+ "project" : envvar .GetTestProjectFromEnv (),
151
+ }
152
+
153
+ acctest .VcrTest (t , resource.TestCase {
154
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
155
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
156
+ Steps : []resource.TestStep {
157
+ {
158
+ Config : testAccComputeNetworkFirewallPolicyRule_addressGroupOrder (context ),
159
+ },
160
+ {
161
+ ResourceName : "google_compute_network_firewall_policy_rule.src_test" ,
162
+ ImportState : true ,
163
+ ImportStateVerify : true ,
164
+ // Referencing using ID causes import to fail
165
+ // Client-side reordering doesn't work with no state, so ignore on import
166
+ ImportStateVerifyIgnore : []string {"firewall_policy" , "match.0.src_address_groups" },
167
+ },
168
+ {
169
+ ResourceName : "google_compute_network_firewall_policy_rule.dest_test" ,
170
+ ImportState : true ,
171
+ ImportStateVerify : true ,
172
+ // Referencing using ID causes import to fail
173
+ // Client-side reordering doesn't work with no state, so ignore on import
174
+ ImportStateVerifyIgnore : []string {"firewall_policy" , "match.0.dest_address_groups" },
175
+ },
176
+ },
177
+ })
178
+ }
179
+
145
180
func TestAccComputeNetworkFirewallPolicyRule_securityProfileGroup_update (t * testing.T ) {
146
181
t .Parallel ()
147
182
@@ -898,3 +933,72 @@ resource "google_compute_network_firewall_policy_rule" "fw_policy_rule3" {
898
933
}
899
934
` , context )
900
935
}
936
+
937
+ func testAccComputeNetworkFirewallPolicyRule_addressGroupOrder (context map [string ]interface {}) string {
938
+ return acctest .Nprintf (`
939
+ resource "google_compute_network_firewall_policy" "policy" {
940
+ name = "tf-test-policy-%{random_suffix}"
941
+ description = "Resource created for Terraform acceptance testing"
942
+ }
943
+
944
+ resource "google_network_security_address_group" "add-group1" {
945
+ name = "tf-test-group-1-%{random_suffix}"
946
+ parent = "projects/%{project}"
947
+ location = "global"
948
+ type = "IPV4"
949
+ capacity = "10"
950
+ items = ["10.0.1.1/32"]
951
+ }
952
+ resource "google_network_security_address_group" "add-group2" {
953
+ name = "tf-test-group-2-%{random_suffix}"
954
+ parent = "projects/%{project}"
955
+ location = "global"
956
+ type = "IPV4"
957
+ capacity = "10"
958
+ items = ["10.0.2.2/32"]
959
+ }
960
+ resource "google_network_security_address_group" "add-group3" {
961
+ name = "tf-test-group-3-%{random_suffix}"
962
+ parent = "projects/%{project}"
963
+ location = "global"
964
+ type = "IPV4"
965
+ capacity = "10"
966
+ items = ["10.0.3.3/32"]
967
+ }
968
+
969
+ resource "google_compute_network_firewall_policy_rule" "src_test" {
970
+ firewall_policy = google_compute_network_firewall_policy.policy.id
971
+ action = "allow"
972
+ priority = 1000
973
+ description = "Testing address group order issue"
974
+ direction = "INGRESS"
975
+ enable_logging = true
976
+ match {
977
+ src_address_groups = [google_network_security_address_group.add-group2.id,
978
+ google_network_security_address_group.add-group1.id]
979
+ dest_ip_ranges = ["192.168.2.0/24", "10.0.3.4/32"]
980
+ layer4_configs {
981
+ ip_protocol = "all"
982
+ }
983
+ }
984
+ }
985
+
986
+ resource "google_compute_network_firewall_policy_rule" "dest_test" {
987
+ firewall_policy = google_compute_network_firewall_policy.policy.id
988
+ action = "allow"
989
+ priority = 1100
990
+ description = "Testing address group order issue"
991
+ direction = "EGRESS"
992
+ enable_logging = true
993
+ match {
994
+ dest_address_groups = [google_network_security_address_group.add-group3.id,
995
+ google_network_security_address_group.add-group2.id]
996
+ src_ip_ranges = ["192.168.2.0/24", "10.0.3.4/32"]
997
+ layer4_configs {
998
+ ip_protocol = "all"
999
+ }
1000
+ }
1001
+ }
1002
+
1003
+ ` , context )
1004
+ }
0 commit comments