diff --git a/third_party/terraform/resources/resource_bigtable_gc_policy.go b/third_party/terraform/resources/resource_bigtable_gc_policy.go index aa40d98ccfce..28caf60de89c 100644 --- a/third_party/terraform/resources/resource_bigtable_gc_policy.go +++ b/third_party/terraform/resources/resource_bigtable_gc_policy.go @@ -24,9 +24,10 @@ func resourceBigtableGCPolicy() *schema.Resource { Schema: map[string]*schema.Schema{ "instance_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: compareResourceNames, }, "table": { @@ -95,11 +96,12 @@ func resourceBigtableGCPolicyCreate(d *schema.ResourceData, meta interface{}) er return err } - instanceName := d.Get("instance_name").(string) + instanceName := GetResourceNameFromSelfLink(d.Get("instance_name").(string)) c, err := config.bigtableClientFactory.NewAdminClient(project, instanceName) if err != nil { return fmt.Errorf("Error starting admin client. %s", err) } + d.Set("instance_name", instanceName) defer c.Close() @@ -138,7 +140,7 @@ func resourceBigtableGCPolicyRead(d *schema.ResourceData, meta interface{}) erro return err } - instanceName := d.Get("instance_name").(string) + instanceName := GetResourceNameFromSelfLink(d.Get("instance_name").(string)) c, err := config.bigtableClientFactory.NewAdminClient(project, instanceName) if err != nil { return fmt.Errorf("Error starting admin client. %s", err) @@ -175,7 +177,7 @@ func resourceBigtableGCPolicyDestroy(d *schema.ResourceData, meta interface{}) e return err } - instanceName := d.Get("instance_name").(string) + instanceName := GetResourceNameFromSelfLink(d.Get("instance_name").(string)) c, err := config.bigtableClientFactory.NewAdminClient(project, instanceName) if err != nil { return fmt.Errorf("Error starting admin client. %s", err) diff --git a/third_party/terraform/resources/resource_bigtable_table.go b/third_party/terraform/resources/resource_bigtable_table.go index 4c63a6dbf193..c5d001547d77 100644 --- a/third_party/terraform/resources/resource_bigtable_table.go +++ b/third_party/terraform/resources/resource_bigtable_table.go @@ -40,9 +40,10 @@ func resourceBigtableTable() *schema.Resource { }, "instance_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: compareResourceNames, }, "split_keys": { @@ -71,11 +72,12 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error return err } - instanceName := d.Get("instance_name").(string) + instanceName := GetResourceNameFromSelfLink(d.Get("instance_name").(string)) c, err := config.bigtableClientFactory.NewAdminClient(project, instanceName) if err != nil { return fmt.Errorf("Error starting admin client. %s", err) } + d.Set("instance_name", instanceName) defer c.Close() @@ -129,7 +131,7 @@ func resourceBigtableTableRead(d *schema.ResourceData, meta interface{}) error { return err } - instanceName := d.Get("instance_name").(string) + instanceName := GetResourceNameFromSelfLink(d.Get("instance_name").(string)) c, err := config.bigtableClientFactory.NewAdminClient(project, instanceName) if err != nil { return fmt.Errorf("Error starting admin client. %s", err) @@ -160,7 +162,7 @@ func resourceBigtableTableDestroy(d *schema.ResourceData, meta interface{}) erro return err } - instanceName := d.Get("instance_name").(string) + instanceName := GetResourceNameFromSelfLink(d.Get("instance_name").(string)) c, err := config.bigtableClientFactory.NewAdminClient(project, instanceName) if err != nil { return fmt.Errorf("Error starting admin client. %s", err) diff --git a/third_party/terraform/tests/resource_bigtable_gc_policy_test.go b/third_party/terraform/tests/resource_bigtable_gc_policy_test.go index 904da3027170..9312c2df8cd4 100644 --- a/third_party/terraform/tests/resource_bigtable_gc_policy_test.go +++ b/third_party/terraform/tests/resource_bigtable_gc_policy_test.go @@ -139,7 +139,7 @@ resource "google_bigtable_instance" "instance" { resource "google_bigtable_table" "table" { name = "%s" - instance_name = google_bigtable_instance.instance.name + instance_name = google_bigtable_instance.instance.id column_family { family = "%s" @@ -147,7 +147,7 @@ resource "google_bigtable_table" "table" { } resource "google_bigtable_gc_policy" "policy" { - instance_name = google_bigtable_instance.instance.name + instance_name = google_bigtable_instance.instance.id table = google_bigtable_table.table.name column_family = "%s" diff --git a/third_party/terraform/tests/resource_bigtable_table_test.go b/third_party/terraform/tests/resource_bigtable_table_test.go index 48608f8ab27e..bfb89a578170 100644 --- a/third_party/terraform/tests/resource_bigtable_table_test.go +++ b/third_party/terraform/tests/resource_bigtable_table_test.go @@ -143,7 +143,7 @@ resource "google_bigtable_instance" "instance" { resource "google_bigtable_table" "table" { name = "%s" - instance_name = google_bigtable_instance.instance.name + instance_name = google_bigtable_instance.instance.id } `, instanceName, instanceName, tableName) } @@ -161,7 +161,7 @@ resource "google_bigtable_instance" "instance" { resource "google_bigtable_table" "table" { name = "%s" - instance_name = google_bigtable_instance.instance.name + instance_name = google_bigtable_instance.instance.id split_keys = ["a", "b", "c"] } `, instanceName, instanceName, tableName)