Skip to content

Commit

Permalink
fix reserved_ip_range (#5220) (#10146)
Browse files Browse the repository at this point in the history
* fix reserved_ip_range

* add a test

* fixes lint error

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Sep 23, 2021
1 parent f9ddad4 commit 43c1f1e
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/5220.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
filestore: fixed `reserved_ip_range` can't be updated on `google_filestore_instance`
```
1 change: 1 addition & 0 deletions google/resource_filestore_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ instance is connected.`,
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
Description: `A /29 CIDR block that identifies the range of IP
addresses reserved for this instance.`,
},
Expand Down
150 changes: 149 additions & 1 deletion google/resource_filestore_instance_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,151 @@
package google

// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now.
import (
"fmt"
"testing"

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

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

name := fmt.Sprintf("tf-test-%d", randInt(t))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_update(name),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccFilestoreInstance_update2(name),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccFilestoreInstance_update(name string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
zone = "us-central1-b"
file_shares {
capacity_gb = 2660
name = "share"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
}
labels = {
baz = "qux"
}
tier = "PREMIUM"
description = "An instance created during testing."
}
`, name)
}

func testAccFilestoreInstance_update2(name string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
zone = "us-central1-b"
file_shares {
capacity_gb = 2760
name = "share"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
}
tier = "PREMIUM"
description = "A modified instance created during testing."
}
`, name)
}

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

name := fmt.Sprintf("tf-test-%d", randInt(t))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_reservedIpRange_update(name),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccFilestoreInstance_reservedIpRange_update2(name),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccFilestoreInstance_reservedIpRange_update(name string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
zone = "us-central1-b"
tier = "BASIC_HDD"
file_shares {
capacity_gb = 1024
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
reserved_ip_range = "172.19.30.0/29"
}
}
`, name)
}

func testAccFilestoreInstance_reservedIpRange_update2(name string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
zone = "us-central1-b"
tier = "BASIC_HDD"
file_shares {
capacity_gb = 1024
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
reserved_ip_range = "172.19.31.0/29"
}
}
`, name)
}

0 comments on commit 43c1f1e

Please sign in to comment.