-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added backup support for
google_filestore_instance
(#6742)
Co-authored-by: Cameron Thornton <camthornton@google.com> fixes hashicorp/terraform-provider-google#7655
- Loading branch information
Showing
4 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
mmv1/templates/terraform/examples/filestore_backup_basic.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
resource "google_filestore_instance" "instance" { | ||
name = "<%= ctx[:vars]["instance_name"] %>" | ||
location = "us-central1-b" | ||
tier = "BASIC_SSD" | ||
|
||
file_shares { | ||
capacity_gb = 2560 | ||
name = "share1" | ||
} | ||
|
||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
connect_mode = "DIRECT_PEERING" | ||
} | ||
} | ||
|
||
resource "google_filestore_backup" "<%= ctx[:primary_resource_id] %>" { | ||
name = "<%= ctx[:vars]["backup_name"] %>" | ||
location = "us-central1" | ||
source_instance = google_filestore_instance.instance.id | ||
source_file_share = "share1" | ||
|
||
description = "This is a filestore backup for the test instance" | ||
labels = { | ||
"files":"label1", | ||
"other-label": "label2" | ||
} | ||
} | ||
|
115 changes: 115 additions & 0 deletions
115
mmv1/third_party/terraform/tests/resource_filestore_backup_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccFilestoreBackup_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
instName := fmt.Sprintf("tf-fs-inst-%d", randInt(t)) | ||
bkupName := fmt.Sprintf("tf-fs-bkup-%d", randInt(t)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckFilestoreBackupDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFilestoreBackup_create(instName, bkupName), | ||
}, | ||
{ | ||
ResourceName: "google_filestore_backup.backup", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"location"}, | ||
}, | ||
{ | ||
Config: testAccFilestoreBackup_update(instName, bkupName), | ||
}, | ||
{ | ||
ResourceName: "google_filestore_backup.backup", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "description", "location"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFilestoreBackup_create(instName string, bkupName string) string { | ||
return fmt.Sprintf(` | ||
resource "google_filestore_instance" "instance" { | ||
name = "%s" | ||
location = "us-central1-b" | ||
tier = "BASIC_SSD" | ||
file_shares { | ||
capacity_gb = 2560 | ||
name = "share22" | ||
} | ||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
connect_mode = "DIRECT_PEERING" | ||
} | ||
description = "An instance created during testing." | ||
} | ||
resource "google_filestore_backup" "backup" { | ||
name = "%s" | ||
location = "us-central1" | ||
source_instance = google_filestore_instance.instance.id | ||
source_file_share = "share22" | ||
description = "This is a filestore backup for the test instance" | ||
} | ||
`, instName, bkupName) | ||
} | ||
|
||
func testAccFilestoreBackup_update(instName string, bkupName string) string { | ||
return fmt.Sprintf(` | ||
resource "google_filestore_instance" "instance" { | ||
name = "%s" | ||
location = "us-central1-b" | ||
tier = "BASIC_SSD" | ||
file_shares { | ||
capacity_gb = 2560 | ||
name = "share22" | ||
} | ||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
connect_mode = "DIRECT_PEERING" | ||
} | ||
labels = { | ||
"files":"label1", | ||
"other-label": "update" | ||
} | ||
description = "A modified instance during testing." | ||
} | ||
resource "google_filestore_backup" "backup" { | ||
name = "%s" | ||
location = "us-central1" | ||
source_instance = google_filestore_instance.instance.id | ||
source_file_share = "share22" | ||
description = "This is an updated filestore backup for the test instance" | ||
labels = { | ||
"files":"label1", | ||
"other-label": "update" | ||
} | ||
} | ||
`, instName, bkupName) | ||
} |