@@ -458,7 +458,31 @@ func testAccCheckOrgPolicyPolicyDestroyProducer(t *testing.T) func(s *terraform.
458
458
return nil
459
459
}
460
460
}
461
-
461
+ func TestAccOrgPolicyPolicy_EnforceParameterizedMCPolicy (t * testing.T ) {
462
+ t .Parallel ()
463
+
464
+ context := map [string ]interface {}{
465
+ "org_id" : envvar .GetTestOrgFromEnv (t ),
466
+ "random_suffix" : acctest .RandString (t , 10 ),
467
+ }
468
+
469
+ acctest .VcrTest (t , resource.TestCase {
470
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
471
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
472
+ CheckDestroy : testAccCheckOrgPolicyPolicyDestroyProducer (t ),
473
+ Steps : []resource.TestStep {
474
+ {
475
+ Config : testAccOrgPolicyPolicy_EnforceParameterizedMCPolicy (context ),
476
+ },
477
+ {
478
+ ResourceName : "google_org_policy_policy.primary" ,
479
+ ImportState : true ,
480
+ ImportStateVerify : true ,
481
+ ImportStateVerifyIgnore : []string {"name" , "spec.0.rules.0.condition.0.expression" },
482
+ },
483
+ },
484
+ })
485
+ }
462
486
func testAccOrgPolicyPolicy_EnforceParameterizedMCPolicy (context map [string ]interface {}) string {
463
487
return acctest .Nprintf (`
464
488
resource "google_org_policy_policy" "primary" {
@@ -484,5 +508,58 @@ resource "google_project" "basic" {
484
508
}
485
509
486
510
511
+ ` , context )
512
+ }
513
+
514
+ func TestAccOrgPolicyPolicy_EnforceParameterizedMCDryRunPolicy (t * testing.T ) {
515
+ t .Parallel ()
516
+
517
+ context := map [string ]interface {}{
518
+ "org_id" : envvar .GetTestOrgFromEnv (t ),
519
+ "random_suffix" : acctest .RandString (t , 10 ),
520
+ }
521
+
522
+ acctest .VcrTest (t , resource.TestCase {
523
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
524
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
525
+ CheckDestroy : testAccCheckOrgPolicyPolicyDestroyProducer (t ),
526
+ Steps : []resource.TestStep {
527
+ {
528
+ Config : testAccOrgPolicyPolicy_EnforceParameterizedMCDryRunPolicy (context ),
529
+ },
530
+ {
531
+ ResourceName : "google_org_policy_policy.primary" ,
532
+ ImportState : true ,
533
+ ImportStateVerify : true ,
534
+ ImportStateVerifyIgnore : []string {"name" , "spec.0.rules.0.condition.0.expression" },
535
+ },
536
+ },
537
+ })
538
+ }
539
+ func testAccOrgPolicyPolicy_EnforceParameterizedMCDryRunPolicy (context map [string ]interface {}) string {
540
+ return acctest .Nprintf (`
541
+ resource "google_org_policy_policy" "primary" {
542
+ name = "projects/${google_project.basic.name}/policies/constraints/compute.managed.restrictDiskCreation"
543
+ parent = "projects/${google_project.basic.name}"
544
+
545
+ dry_run_spec {
546
+ rules {
547
+ enforce = "TRUE"
548
+ parameters {
549
+ "isSizeLimitCheck" = True,
550
+ "allowedDiskTypes" = ["pd-ssd"]
551
+ }
552
+ }
553
+ }
554
+ }
555
+
556
+ resource "google_project" "basic" {
557
+ project_id = "tf-test-id%{random_suffix}"
558
+ name = "tf-test-id%{random_suffix}"
559
+ org_id = "%{org_id}"
560
+ deletion_policy = "DELETE"
561
+ }
562
+
563
+
487
564
` , context )
488
565
}
0 commit comments