From b0e490a100ffcb72a116e84335b7e65acbf4daf8 Mon Sep 17 00:00:00 2001 From: megan07 Date: Fri, 2 Aug 2019 20:30:11 +0000 Subject: [PATCH] set max bigtable instance cluster to 4 Signed-off-by: Modular Magician --- google/resource_bigtable_instance.go | 2 +- google/resource_bigtable_instance_test.go | 57 ++++++++++++++++++++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/google/resource_bigtable_instance.go b/google/resource_bigtable_instance.go index 1d30ac2e2d1..ed1435b54d5 100644 --- a/google/resource_bigtable_instance.go +++ b/google/resource_bigtable_instance.go @@ -28,7 +28,7 @@ func resourceBigtableInstance() *schema.Resource { Type: schema.TypeSet, Required: true, ForceNew: true, - MaxItems: 2, + MaxItems: 4, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "cluster_id": { diff --git a/google/resource_bigtable_instance_test.go b/google/resource_bigtable_instance_test.go index cf878307a33..d3bb9d69cc4 100644 --- a/google/resource_bigtable_instance_test.go +++ b/google/resource_bigtable_instance_test.go @@ -3,6 +3,7 @@ package google import ( "context" "fmt" + "regexp" "testing" "github.com/hashicorp/terraform/helper/acctest" @@ -48,6 +49,10 @@ func TestAccBigtableInstance_cluster(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckBigtableInstanceDestroy, Steps: []resource.TestStep{ + { + Config: testAccBigtableInstance_clusterMax(instanceName), + ExpectError: regexp.MustCompile("config is invalid: Too many cluster blocks: No more than 4 \"cluster\" blocks are allowed"), + }, { Config: testAccBigtableInstance_cluster(instanceName), Check: resource.ComposeTestCheckFunc( @@ -152,18 +157,68 @@ resource "google_bigtable_instance" "instance" { name = "%s" cluster { cluster_id = "%s-a" + zone = "us-central1-a" + num_nodes = 3 + storage_type = "HDD" + } + cluster { + cluster_id = "%s-b" zone = "us-central1-b" num_nodes = 3 storage_type = "HDD" } + cluster { + cluster_id = "%s-c" + zone = "us-central1-c" + num_nodes = 3 + storage_type = "HDD" + } + cluster { + cluster_id = "%s-d" + zone = "us-central1-f" + num_nodes = 3 + storage_type = "HDD" + } +} +`, instanceName, instanceName, instanceName, instanceName, instanceName) +} + +func testAccBigtableInstance_clusterMax(instanceName string) string { + return fmt.Sprintf(` +resource "google_bigtable_instance" "instance" { + name = "%s" + cluster { + cluster_id = "%s-a" + zone = "us-central1-a" + num_nodes = 3 + storage_type = "HDD" + } cluster { cluster_id = "%s-b" + zone = "us-central1-b" + num_nodes = 3 + storage_type = "HDD" + } + cluster { + cluster_id = "%s-c" zone = "us-central1-c" num_nodes = 3 storage_type = "HDD" } + cluster { + cluster_id = "%s-d" + zone = "us-central1-f" + num_nodes = 3 + storage_type = "HDD" + } + cluster { + cluster_id = "%s-e" + zone = "us-east1-a" + num_nodes = 3 + storage_type = "HDD" + } } -`, instanceName, instanceName, instanceName) +`, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName) } func testAccBigtableInstance_development(instanceName string) string {