@@ -149,6 +149,81 @@ func TestAccComputeFirewallPolicyRule_securityProfileGroup_update(t *testing.T)
149
149
})
150
150
}
151
151
152
+ func TestAccComputeFirewallPolicyRule_basic (t * testing.T ) {
153
+ t .Parallel ()
154
+
155
+ context := map [string ]interface {}{
156
+ "random_suffix" : acctest .RandString (t , 10 ),
157
+ "org_name" : fmt .Sprintf ("organizations/%s" , envvar .GetTestOrgFromEnv (t )),
158
+ }
159
+
160
+ acctest .VcrTest (t , resource.TestCase {
161
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
162
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
163
+ Steps : []resource.TestStep {
164
+ {
165
+ Config : testAccComputeFirewallPolicyRule_basic (context ),
166
+ },
167
+ {
168
+ ResourceName : "google_compute_firewall_policy_rule.fw_policy_rule" ,
169
+ ImportState : true ,
170
+ ImportStateVerify : true ,
171
+ // Referencing using ID causes import to fail
172
+ ImportStateVerifyIgnore : []string {"firewall_policy" },
173
+ },
174
+ },
175
+ })
176
+ }
177
+
178
+ func testAccComputeFirewallPolicyRule_basic (context map [string ]interface {}) string {
179
+ return acctest .Nprintf (`
180
+ resource "google_folder" "folder" {
181
+ display_name = "tf-test-folder-%{random_suffix}"
182
+ parent = "%{org_name}"
183
+ deletion_protection = false
184
+ }
185
+
186
+ resource "google_compute_firewall_policy" "fw_policy" {
187
+ parent = google_folder.folder.name
188
+ short_name = "tf-test-policy-%{random_suffix}"
189
+ description = "Resource created for Terraform acceptance testing"
190
+ }
191
+
192
+ resource "google_network_security_address_group" "address_group" {
193
+ name = "tf-test-policy-%{random_suffix}"
194
+ parent = "%{org_name}"
195
+ description = "Sample global networksecurity_address_group"
196
+ location = "global"
197
+ items = ["208.80.154.224/32"]
198
+ type = "IPV4"
199
+ capacity = 100
200
+ }
201
+
202
+ resource "google_compute_firewall_policy_rule" "fw_policy_rule" {
203
+ firewall_policy = google_compute_firewall_policy.fw_policy.id
204
+ description = "Resource created for Terraform acceptance testing"
205
+ priority = 9000
206
+ enable_logging = true
207
+ action = "allow"
208
+ direction = "EGRESS"
209
+ disabled = false
210
+ tls_inspect = false
211
+
212
+ match {
213
+ layer4_configs {
214
+ ip_protocol = "tcp"
215
+ ports = [80, 8080]
216
+ }
217
+ dest_ip_ranges = ["11.100.0.1/32"]
218
+ dest_fqdns = ["google.com"]
219
+ dest_region_codes = ["US"]
220
+ dest_threat_intelligences = ["iplist-known-malicious-ips"]
221
+ dest_address_groups = [google_network_security_address_group.address_group.id]
222
+ }
223
+ }
224
+ ` , context )
225
+ }
226
+
152
227
func testAccComputeFirewallPolicyRule_securityProfileGroup_basic (context map [string ]interface {}) string {
153
228
return acctest .Nprintf (`
154
229
resource "google_folder" "folder" {
@@ -366,13 +441,14 @@ resource "google_network_security_address_group" "address_group" {
366
441
}
367
442
368
443
resource "google_compute_firewall_policy_rule" "fw_policy_rule1" {
369
- firewall_policy = google_compute_firewall_policy.fw_policy.id
370
- description = "Resource created for Terraform acceptance testing"
371
- priority = 9000
372
- enable_logging = true
373
- action = "allow"
374
- direction = "EGRESS"
375
- disabled = false
444
+ firewall_policy = google_compute_firewall_policy.fw_policy.id
445
+ description = "Resource created for Terraform acceptance testing"
446
+ priority = 9000
447
+ enable_logging = true
448
+ action = "allow"
449
+ direction = "EGRESS"
450
+ disabled = false
451
+
376
452
target_service_accounts = [google_service_account.service_account.email]
377
453
target_resources = [
378
454
google_compute_network.network1.self_link,
@@ -442,13 +518,14 @@ resource "google_network_security_address_group" "address_group" {
442
518
}
443
519
444
520
resource "google_compute_firewall_policy_rule" "fw_policy_rule1" {
445
- firewall_policy = google_compute_firewall_policy.fw_policy.id
446
- description = "Test description"
447
- priority = 9000
448
- enable_logging = false
449
- action = "deny"
450
- direction = "INGRESS"
451
- disabled = true
521
+ firewall_policy = google_compute_firewall_policy.fw_policy.id
522
+ description = "Test description"
523
+ priority = 9000
524
+ enable_logging = false
525
+ action = "deny"
526
+ direction = "INGRESS"
527
+ disabled = false
528
+
452
529
target_resources = [google_compute_network.network1.self_link]
453
530
target_service_accounts = [
454
531
google_service_account.service_account.email,
0 commit comments