Skip to content
Open
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
11 changes: 11 additions & 0 deletions mmv1/products/filestore/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ properties:
projects/{projectId}/locations/{locationId}/backups/{backupId},
that this file share has been restored from.
immutable: true
conflicts:
- 'sourceBackupdrBackup'
- name: 'sourceBackupdrBackup'
type: String
description: |
The resource name of the BackupDR backup, in the format
`projects/{project_id}/locations/{location_id}/backupVaults/{backupvault_id}/dataSources/{datasource_id}/backups/{backup_id}`,
that this file share has been restored from.
immutable: true
conflicts:
- 'sourceBackup'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI conflicts doesn't work within array types in Terraform. It's a limitation of the implementation in Terraform itself unfortunately

- name: 'nfsExportOptions'
type: Array
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package filestore_test

import (
"fmt"
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand Down Expand Up @@ -180,3 +181,93 @@ resource "google_filestore_backup" "backup" {
}
`, context)
}

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

name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
backupName := "projects/my-project/locations/us-central1/backupVaults/my-vault/dataSources/my-source/backups/my-backup"

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_restoreBackupDR(name, backupName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_filestore_instance.instance", "file_shares.0.source_backupdr_backup", backupName),
),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"zone", "location"},
},
},
})
}

func testAccFilestoreInstance_restoreBackupDR(name, backupName string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
location = "us-central1-b"
tier = "BASIC_HDD"

file_shares {
capacity_gb = 1024
name = "share"
source_backupdr_backup = "%s"
}

networks {
network = "default"
modes = ["MODE_IPV4"]
}
}
`, name, backupName)
}

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

name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
backupName := "projects/my-project/locations/us-central1/backups/my-backup"
backupdrName := "projects/my-project/locations/us-central1/backupVaults/my-vault/dataSources/my-source/backups/my-backup"

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_sourceBackupDRConflicts(name, backupName, backupdrName),
ExpectError: regexp.MustCompile(`"source_backupdr_backup": conflicts with "source_backup"`),
},
},
})
}

func testAccFilestoreInstance_sourceBackupDRConflicts(name, backupName, backupdrName string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
location = "us-central1-b"
tier = "BASIC_HDD"

file_shares {
capacity_gb = 1024
name = "share"
source_backup = "%s"
source_backupdr_backup = "%s"
}

networks {
network = "default"
modes = ["MODE_IPV4"]
}
}
`, name, backupName, backupdrName)
}
Loading