@@ -659,3 +659,111 @@ resource "google_dns_managed_zone" "foobar" {
659659}
660660` , suffix , suffix , description , project )
661661}
662+
663+ func TestAccDNSManagedZone_dnsManagedZoneUpdateWithServiceDirectory (t * testing.T ) {
664+ t .Parallel ()
665+
666+ context := map [string ]interface {}{
667+ "random_suffix" : acctest .RandString (t , 10 ),
668+ }
669+
670+ acctest .VcrTest (t , resource.TestCase {
671+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
672+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderBetaFactories (t ),
673+ CheckDestroy : testAccCheckDNSManagedZoneDestroyProducer (t ),
674+ Steps : []resource.TestStep {
675+ {
676+ Config : testAccDNSManagedZone_dnsManagedZoneWithServiceDirectory (context ),
677+ },
678+ {
679+ ResourceName : "google_dns_managed_zone.sd-zone" ,
680+ ImportState : true ,
681+ ImportStateVerify : true ,
682+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
683+ },
684+ {
685+ Config : testAccDNSManagedZone_dnsManagedZoneWithServiceDirectoryUpdate (context ),
686+ },
687+ {
688+ ResourceName : "google_dns_managed_zone.sd-zone" ,
689+ ImportState : true ,
690+ ImportStateVerify : true ,
691+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
692+ },
693+ },
694+ })
695+ }
696+
697+ func testAccDNSManagedZone_dnsManagedZoneWithServiceDirectory (context map [string ]interface {}) string {
698+ return acctest .Nprintf (`
699+ resource "google_dns_managed_zone" "sd-zone" {
700+ provider = google-beta
701+
702+ name = "tf-test-peering-zone%{random_suffix}"
703+ dns_name = "services.example.com."
704+ description = "Example private DNS Service Directory zone"
705+
706+ visibility = "private"
707+
708+ service_directory_config {
709+ namespace {
710+ namespace_url = google_service_directory_namespace.example.id
711+ }
712+ }
713+ }
714+
715+ resource "google_service_directory_namespace" "example" {
716+ provider = google-beta
717+
718+ namespace_id = "tf-test-example%{random_suffix}"
719+ location = "us-central1"
720+ }
721+
722+ resource "google_compute_network" "network" {
723+ provider = google-beta
724+
725+ name = "tf-test-network%{random_suffix}"
726+ auto_create_subnetworks = false
727+ }
728+ ` , context )
729+ }
730+
731+ func testAccDNSManagedZone_dnsManagedZoneWithServiceDirectoryUpdate (context map [string ]interface {}) string {
732+ return acctest .Nprintf (`
733+ resource "google_dns_managed_zone" "sd-zone" {
734+ provider = google-beta
735+
736+ name = "tf-test-peering-zone%{random_suffix}"
737+ dns_name = "services.example.com."
738+ description = "Example private DNS Service Directory zone"
739+
740+ visibility = "private"
741+
742+ private_visibility_config {
743+ networks {
744+ network_url = google_compute_network.network.id
745+ }
746+ }
747+
748+ service_directory_config {
749+ namespace {
750+ namespace_url = google_service_directory_namespace.example.id
751+ }
752+ }
753+ }
754+
755+ resource "google_service_directory_namespace" "example" {
756+ provider = google-beta
757+
758+ namespace_id = "tf-test-example%{random_suffix}"
759+ location = "us-central1"
760+ }
761+
762+ resource "google_compute_network" "network" {
763+ provider = google-beta
764+
765+ name = "tf-test-network%{random_suffix}"
766+ auto_create_subnetworks = false
767+ }
768+ ` , context )
769+ }
0 commit comments