Skip to content

Commit

Permalink
handle case where bigtable development instances have one node (#3057) (
Browse files Browse the repository at this point in the history
#5557)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 31, 2020
1 parent af85f85 commit 3a1986e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/3057.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigtable: fixed diff for DEVELOPMENT instances that are returned from the API with one node
```
9 changes: 6 additions & 3 deletions google/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ func resourceBigtableInstance() *schema.Resource {
Required: true,
},
"num_nodes": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
// DEVELOPMENT instances could get returned with either zero or one node,
// so mark as computed.
Computed: true,
ValidateFunc: validation.IntAtLeast(3),
},
"storage_type": {
Expand Down Expand Up @@ -311,7 +314,7 @@ func resourceBigtableInstanceValidateDevelopment(diff *schema.ResourceDiff, meta
if diff.Get("cluster.#").(int) != 1 {
return fmt.Errorf("config is invalid: instance with instance_type=\"DEVELOPMENT\" should have exactly one \"cluster\" block")
}
if diff.Get("cluster.0.num_nodes").(int) != 0 {
if diff.Get("cluster.0.num_nodes").(int) > 1 {
return fmt.Errorf("config is invalid: num_nodes cannot be set for instance_type=\"DEVELOPMENT\"")
}
return nil
Expand Down
1 change: 1 addition & 0 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

sqladmin "google.golang.org/api/sqladmin/v1beta4"
)

Expand Down

0 comments on commit 3a1986e

Please sign in to comment.