@@ -478,7 +478,7 @@ func TestAccFilestoreInstance_replication(t *testing.T) {
478478 resource .TestCheckResourceAttr (
479479 "google_filestore_instance.replica_instance" ,
480480 "effective_replication.0.replicas.0.peer_instance" ,
481- "projects/" + context["project"].(string) + "/locations/us-east1/instances/tf-test-source-instance-" + context["random_suffix"].(string),
481+ "projects/" + context ["project" ].(string )+ "/locations/us-east1/instances/tf-test-source-instance-" + context ["random_suffix" ].(string ),
482482 ),
483483 resource .TestCheckResourceAttr (
484484 "google_filestore_instance.replica_instance" ,
@@ -541,8 +541,6 @@ resource "google_filestore_instance" "replica_instance" {
541541` , context )
542542}
543543
544- {{- if ne $.TargetVersionName "ga" }}
545-
546544func TestAccFilestoreInstance_directoryServices (t * testing.T ) {
547545 t .Parallel ()
548546
@@ -552,14 +550,41 @@ func TestAccFilestoreInstance_directoryServices(t *testing.T) {
552550
553551 acctest .VcrTest (t , resource.TestCase {
554552 PreCheck : func () { acctest .AccTestPreCheck (t ) },
555- ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories (t),
553+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
556554 CheckDestroy : testAccCheckFilestoreInstanceDestroyProducer (t ),
557555 Steps : []resource.TestStep {
558556 {
559- Config: testAccFilestoreInstance_ldap(name, location, tier),
557+ Config : testAccFilestoreInstance_ldap (name , location , tier , "example.com" ),
558+ Check : resource .ComposeTestCheckFunc (
559+ resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.domain" , "example.com" ),
560+ resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.servers.0" , "ldap.example.com" ),
561+ resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.users_ou" , "users" ),
562+ resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.groups_ou" , "groups" ),
563+ ),
564+ },
565+ {
566+ ResourceName : "google_filestore_instance.instance" ,
567+ ImportState : true ,
568+ ImportStateVerify : true ,
569+ ImportStateVerifyIgnore : []string {"zone" },
570+ },
571+ {
572+ Config : testAccFilestoreInstance_nfs_v4 (name , location , tier ),
560573 Check : resource .ComposeTestCheckFunc (
561- resource.TestCheckResourceAttr("google_filestore_instance.instance", "directory_services.0.ldap.0.domain", "my-domain.com"),
562- resource.TestCheckResourceAttr("google_filestore_instance.instance", "directory_services.0.ldap.0.servers.0", "ldap.example1.com"),
574+ resource .TestCheckNoResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.domain" ),
575+ ),
576+ },
577+ {
578+ ResourceName : "google_filestore_instance.instance" ,
579+ ImportState : true ,
580+ ImportStateVerify : true ,
581+ ImportStateVerifyIgnore : []string {"zone" },
582+ },
583+ {
584+ Config : testAccFilestoreInstance_ldap (name , location , tier , "example.com" ),
585+ Check : resource .ComposeTestCheckFunc (
586+ resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.domain" , "example.com" ),
587+ resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.servers.0" , "ldap.example.com" ),
563588 resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.users_ou" , "users" ),
564589 resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "directory_services.0.ldap.0.groups_ou" , "groups" ),
565590 ),
@@ -570,14 +595,39 @@ func TestAccFilestoreInstance_directoryServices(t *testing.T) {
570595 ImportStateVerify : true ,
571596 ImportStateVerifyIgnore : []string {"zone" },
572597 },
598+ {
599+ Config : testAccFilestoreInstance_ldap (name , location , tier , "other.com" ),
600+ ExpectError : regexp .MustCompile ("cannot update existing directory services configuration" ),
601+ },
573602 },
574603 })
575604}
576605
577- func testAccFilestoreInstance_ldap(name, location, tier string) string {
606+ func testAccFilestoreInstance_nfs_v4 (name , location , tier string ) string {
607+ return fmt .Sprintf (`
608+ resource "google_filestore_instance" "instance" {
609+ name = "%s"
610+ location = "%s"
611+ tier = "%s"
612+ description = "An instance created during testing."
613+ protocol = "NFS_V4_1"
614+
615+ file_shares {
616+ capacity_gb = 1024
617+ name = "share"
618+ }
619+
620+ networks {
621+ network = "default"
622+ modes = ["MODE_IPV4"]
623+ }
624+ }
625+ ` , name , location , tier )
626+ }
627+
628+ func testAccFilestoreInstance_ldap (name , location , tier , domain string ) string {
578629 return fmt .Sprintf (`
579630resource "google_filestore_instance" "instance" {
580- provider = google-beta
581631 name = "%s"
582632 location = "%s"
583633 tier = "%s"
@@ -596,18 +646,16 @@ resource "google_filestore_instance" "instance" {
596646
597647 directory_services {
598648 ldap {
599- domain = "my-domain.com "
600- servers = ["ldap.example1 .com"]
649+ domain = "%s "
650+ servers = ["ldap.example .com"]
601651 users_ou = "users"
602652 groups_ou = "groups"
603653 }
604654 }
605655}
606- `, name, location, tier)
656+ ` , name , location , tier , domain )
607657}
608658
609- {{- end }}
610-
611659func TestAccFilestoreInstance_psc (t * testing.T ) {
612660 t .Parallel ()
613661
@@ -624,7 +672,7 @@ func TestAccFilestoreInstance_psc(t *testing.T) {
624672 Steps : []resource.TestStep {
625673 {
626674 Config : testAccFilestoreInstance_psc (context ),
627- Check: resource.ComposeTestCheckFunc(
675+ Check : resource .ComposeTestCheckFunc (
628676 resource .TestCheckResourceAttr ("google_filestore_instance.instance" , "networks.0.connect_mode" , "PRIVATE_SERVICE_CONNECT" ),
629677 ),
630678 },
@@ -757,4 +805,4 @@ resource "google_filestore_instance" "instance" {
757805 }
758806}
759807` , name , location , tier , network )
760- }
808+ }
0 commit comments