diff --git a/.changelog/3057.txt b/.changelog/3057.txt new file mode 100644 index 00000000000..cff8b2345d5 --- /dev/null +++ b/.changelog/3057.txt @@ -0,0 +1,3 @@ +```release-note:bug +bigtable: fixed diff for DEVELOPMENT instances that are returned from the API with one node +``` diff --git a/google/resource_bigtable_instance.go b/google/resource_bigtable_instance.go index e6212ffbbf0..63536e73470 100644 --- a/google/resource_bigtable_instance.go +++ b/google/resource_bigtable_instance.go @@ -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": { @@ -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 diff --git a/google/resource_sql_database_instance_test.go b/google/resource_sql_database_instance_test.go index 6a21cec41f7..1a14fca3674 100644 --- a/google/resource_sql_database_instance_test.go +++ b/google/resource_sql_database_instance_test.go @@ -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" )