Skip to content

Commit 76a8740

Browse files
rileykarsonDmitry Vlasov
authored and
Dmitry Vlasov
committed
Add support for instance_type to google_bigtable_instance. (hashicorp#313)
* govendor fetch cloud.google.com/go/bigtable * Vendor the rest of the stuff. * Add support for instance_type to google_bigtable_instance. * Revendored some packages. * Removed bad packages from vendor.json
1 parent a4bdf3f commit 76a8740

24 files changed

+685
-356
lines changed

google/resource_bigtable_instance.go

+29-9
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ func resourceBigtableInstance() *schema.Resource {
4444
},
4545

4646
"num_nodes": {
47-
Type: schema.TypeInt,
47+
Type: schema.TypeInt,
48+
Optional: true,
49+
ForceNew: true,
50+
},
51+
52+
"instance_type": {
53+
Type: schema.TypeString,
4854
Optional: true,
4955
ForceNew: true,
50-
Default: 3,
51-
ValidateFunc: validation.IntAtLeast(3),
56+
Default: "PRODUCTION",
57+
ValidateFunc: validation.StringInSlice([]string{"DEVELOPMENT", "PRODUCTION"}, false),
5258
},
5359

5460
"storage_type": {
@@ -91,13 +97,27 @@ func resourceBigtableInstanceCreate(d *schema.ResourceData, meta interface{}) er
9197
storageType = bigtable.SSD
9298
}
9399

100+
numNodes := int32(d.Get("num_nodes").(int))
101+
var instanceType bigtable.InstanceType
102+
switch value := d.Get("instance_type"); value {
103+
case "DEVELOPMENT":
104+
instanceType = bigtable.DEVELOPMENT
105+
106+
if numNodes > 0 {
107+
return fmt.Errorf("Can't specify a non-zero number of nodes: %d for DEVELOPMENT Bigtable instance: %s", numNodes, name)
108+
}
109+
case "PRODUCTION":
110+
instanceType = bigtable.PRODUCTION
111+
}
112+
94113
instanceConf := &bigtable.InstanceConf{
95-
InstanceId: name,
96-
DisplayName: displayName.(string),
97-
ClusterId: d.Get("cluster_id").(string),
98-
NumNodes: int32(d.Get("num_nodes").(int)),
99-
StorageType: storageType,
100-
Zone: d.Get("zone").(string),
114+
InstanceId: name,
115+
DisplayName: displayName.(string),
116+
ClusterId: d.Get("cluster_id").(string),
117+
NumNodes: numNodes,
118+
InstanceType: instanceType,
119+
StorageType: storageType,
120+
Zone: d.Get("zone").(string),
101121
}
102122

103123
c, err := config.bigtableClientFactory.NewInstanceAdminClient(project)

google/resource_bigtable_instance_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ func TestAccBigtableInstance_basic(t *testing.T) {
2929
})
3030
}
3131

32+
func TestAccBigtableInstance_development(t *testing.T) {
33+
instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
34+
35+
resource.Test(t, resource.TestCase{
36+
PreCheck: func() { testAccPreCheck(t) },
37+
Providers: testAccProviders,
38+
CheckDestroy: testAccCheckBigtableInstanceDestroy,
39+
Steps: []resource.TestStep{
40+
{
41+
Config: testAccBigtableInstance_development(instanceName),
42+
Check: resource.ComposeTestCheckFunc(
43+
testAccBigtableInstanceExists(
44+
"google_bigtable_instance.instance"),
45+
),
46+
},
47+
},
48+
})
49+
}
50+
3251
func testAccCheckBigtableInstanceDestroy(s *terraform.State) error {
3352
var ctx = context.Background()
3453
for _, rs := range s.RootModule().Resources {
@@ -92,3 +111,14 @@ resource "google_bigtable_instance" "instance" {
92111
}
93112
`, instanceName, instanceName)
94113
}
114+
115+
func testAccBigtableInstance_development(instanceName string) string {
116+
return fmt.Sprintf(`
117+
resource "google_bigtable_instance" "instance" {
118+
name = "%s"
119+
cluster_id = "%s"
120+
zone = "us-central1-b"
121+
instance_type = "DEVELOPMENT"
122+
}
123+
`, instanceName, instanceName)
124+
}

google/resource_bigtable_table_test.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ func testAccBigtableTableExists(n string) resource.TestCheckFunc {
106106
func testAccBigtableTable(instanceName, tableName string) string {
107107
return fmt.Sprintf(`
108108
resource "google_bigtable_instance" "instance" {
109-
name = "%s"
110-
cluster_id = "%s"
111-
zone = "us-central1-b"
112-
num_nodes = 3
113-
storage_type = "HDD"
109+
name = "%s"
110+
cluster_id = "%s"
111+
zone = "us-central1-b"
112+
instance_type = "DEVELOPMENT"
114113
}
115114
116115
resource "google_bigtable_table" "table" {
@@ -123,11 +122,10 @@ resource "google_bigtable_table" "table" {
123122
func testAccBigtableTable_splitKeys(instanceName, tableName string) string {
124123
return fmt.Sprintf(`
125124
resource "google_bigtable_instance" "instance" {
126-
name = "%s"
127-
cluster_id = "%s"
128-
zone = "us-central1-b"
129-
num_nodes = 3
130-
storage_type = "HDD"
125+
name = "%s"
126+
cluster_id = "%s"
127+
zone = "us-central1-b"
128+
instance_type = "DEVELOPMENT"
131129
}
132130
133131
resource "google_bigtable_table" "table" {

vendor/cloud.google.com/go/bigtable/admin.go

+44-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/cloud.google.com/go/bigtable/bigtable.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/cloud.google.com/go/bigtable/filter.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/oauth2/LICENSE

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)