Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filestore instance - make sourceBackup field configureable. #17099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/9794.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
filestore: make source_backup field configurable
```
3 changes: 2 additions & 1 deletion google/services/filestore/resource_filestore_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ for not allowing root access. The default is NO_ROOT_SQUASH. Default value: "NO_
},
"source_backup": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
Description: `The resource name of the backup, in the format
projects/{projectId}/locations/{locationId}/backups/{backupId},
that this file share has been restored from.`,
Expand Down
87 changes: 87 additions & 0 deletions google/services/filestore/resource_filestore_restore_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package filestore_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
)

func TestAccFilestoreInstance_restore(t *testing.T) {
t.Parallel()

srcInstancetName := fmt.Sprintf("tf-fs-inst-source-%d", acctest.RandInt(t))
restoreInstanceName := fmt.Sprintf("tf-fs-inst-restored-%d", acctest.RandInt(t))
backupName := fmt.Sprintf("tf-fs-bkup-%d", acctest.RandInt(t))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstanceRestore_restore(srcInstancetName, restoreInstanceName, backupName),
},
{
ResourceName: "google_filestore_instance.instance_source",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location"},
},
},
})
}

func testAccFilestoreInstanceRestore_restore(srcInstancetName, restoreInstanceName, backupName string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance_source" {
name = "%s"
location = "us-central1-b"
tier = "BASIC_HDD"
description = "An instance created during testing."

file_shares {
capacity_gb = 1024
name = "volume1"
}

networks {
network = "default"
modes = ["MODE_IPV4"]
connect_mode = "DIRECT_PEERING"
}
}

resource "google_filestore_instance" "instance_restored" {
name = "%s"
location = "us-central1-b"
tier = "BASIC_HDD"
description = "An instance created during testing."

file_shares {
capacity_gb = 1024
name = "volume1"
source_backup = google_filestore_backup.backup.id
}

networks {
network = "default"
modes = ["MODE_IPV4"]
connect_mode = "DIRECT_PEERING"
}
}

resource "google_filestore_backup" "backup" {
name = "%s"
location = "us-central1"
source_instance = google_filestore_instance.instance_source.id
source_file_share = "volume1"

description = "This is a filestore backup for the test instance"
}

`, srcInstancetName, restoreInstanceName, backupName)
}
2 changes: 1 addition & 1 deletion website/docs/r/filestore_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ The following arguments are supported:
for the standard tier, or 2560 GiB for the premium tier.

* `source_backup` -
(Output)
(Optional)
The resource name of the backup, in the format
projects/{projectId}/locations/{locationId}/backups/{backupId},
that this file share has been restored from.
Expand Down