Skip to content

Commit b446df3

Browse files
authored
Enable updating directory service config for Filestore instance (#14203)
1 parent bfcc25a commit b446df3

File tree

2 files changed

+64
-23
lines changed

2 files changed

+64
-23
lines changed

mmv1/products/filestore/Instance.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,24 +439,20 @@ properties:
439439
output: true
440440
- name: 'directoryServices'
441441
type: NestedObject
442-
min_version: beta
443442
description: |
444443
Directory Services configuration.
445444
Should only be set if protocol is "NFS_V4_1".
446-
immutable: true
447445
properties:
448446
- name: 'ldap'
449447
type: NestedObject
450448
description: |
451449
Configuration for LDAP servers.
452-
immutable: true
453450
properties:
454451
- name: 'domain'
455452
type: String
456453
required: true
457454
description: |
458455
The LDAP domain name in the format of `my-domain.com`.
459-
immutable: true
460456
- name: 'servers'
461457
required: true
462458
type: Array
@@ -467,7 +463,6 @@ properties:
467463
2. IP address, for example: `10.0.0.1`, `10.0.0.2`, `10.0.0.3`.
468464
All servers names must be in the same format: either all DNS names or all
469465
IP addresses.
470-
immutable: true
471466
item_type:
472467
type: String
473468
- name: 'usersOu'
@@ -476,11 +471,9 @@ properties:
476471
The users Organizational Unit (OU) is optional. This parameter is a hint
477472
to allow faster lookup in the LDAP namespace. In case that this parameter
478473
is not provided, Filestore instance will query the whole LDAP namespace.
479-
immutable: true
480474
- name: 'groupsOu'
481475
type: String
482476
description: |
483477
The groups Organizational Unit (OU) is optional. This parameter is a hint
484478
to allow faster lookup in the LDAP namespace. In case that this parameter
485479
is not provided, Filestore instance will query the whole LDAP namespace.
486-
immutable: true

mmv1/third_party/terraform/services/filestore/resource_filestore_instance_test.go.tmpl renamed to mmv1/third_party/terraform/services/filestore/resource_filestore_instance_test.go

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
546544
func 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(`
579630
resource "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-
611659
func 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

Comments
 (0)