Skip to content

Commit

Permalink
Extract Bigtable instance type from InstanceInfo instead of deriving …
Browse files Browse the repository at this point in the history
…from clusters
  • Loading branch information
nickmoorman committed Oct 17, 2019
1 parent eb875a4 commit 15e8075
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions third_party/terraform/resources/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,21 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro

d.Set("project", project)

var instanceType string
if instance.InstanceType == bigtable.DEVELOPMENT {
instanceType = "DEVELOPMENT"
} else {
instanceType = "PRODUCTION"
}
d.Set("instance_type", instanceType)

clusters, err := c.Clusters(ctx, instance.Name)
if err != nil {
return fmt.Errorf("Error retrieving instance clusters. %s", err)
}

clustersNewState := []map[string]interface{}{}
for i, cluster := range clusters {
// DEVELOPMENT clusters have num_nodes = 0 on their first (and only)
// cluster while PRODUCTION clusters will have at least 3.
if i == 0 {
var instanceType string
if cluster.ServeNodes == 0 {
instanceType = "DEVELOPMENT"
} else {
instanceType = "PRODUCTION"
}

d.Set("instance_type", instanceType)
}

clustersNewState = append(clustersNewState, flattenBigtableCluster(cluster))
}

Expand Down

0 comments on commit 15e8075

Please sign in to comment.