From 1c43a528b0368c85abc99c21d6f3ee0147ae6005 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Tue, 8 Mar 2022 21:39:28 +0530 Subject: [PATCH 1/9] Add dialect to spanner database --- mmv1/products/spanner/api.yaml | 13 +++++++++++ mmv1/products/spanner/terraform.yaml | 5 +++++ .../resource_spanner_database_test.go.erb | 22 +++++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mmv1/products/spanner/api.yaml b/mmv1/products/spanner/api.yaml index 118b3ede4301..b97087b2fe9b 100644 --- a/mmv1/products/spanner/api.yaml +++ b/mmv1/products/spanner/api.yaml @@ -209,3 +209,16 @@ objects: description: | Fully qualified name of the KMS key to use to encrypt this database. This key must exist in the same location as the Spanner Database. + - !ruby/object:Api::Type::Enum + name: 'databaseDialect' + description: | + The dialect of the Cloud Spanner Database. + If it is not provided, "DATABASE_DIALECT_UNSPECIFIED" will be used, + which will create a Google Standard SQL database. + Note: Databases that are created with POSTGRESQL dialect do not support + extra DDL statements in the `CreateDatabase` call. We must therefore re-apply + terraform with ddl on the same database after creation. + values: + - :DATABASE_DIALECT_UNSPECIFIED + - :GOOGLE_STANDARD_SQL + - :POSTGRESQL \ No newline at end of file diff --git a/mmv1/products/spanner/terraform.yaml b/mmv1/products/spanner/terraform.yaml index 533b633494b7..facae6d37692 100644 --- a/mmv1/products/spanner/terraform.yaml +++ b/mmv1/products/spanner/terraform.yaml @@ -31,6 +31,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides On older versions, it is strongly recommended to set `lifecycle { prevent_destroy = true }` on databases in order to prevent accidental data loss. See [Terraform docs](https://www.terraform.io/docs/configuration/resources.html#prevent_destroy) for more information on lifecycle parameters. + + Note: Databases that are created with POSTGRESQL dialect do not support + extra DDL statements in the `CreateDatabase` call. We must therefore re-apply + terraform with ddl on the same database after creation. + examples: - !ruby/object:Provider::Terraform::Examples name: "spanner_database_basic" diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index ba176341d3ca..e20be229cc37 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -91,7 +91,13 @@ resource "google_spanner_database" "basic" { ] deletion_protection = false } -`, instanceName, instanceName, databaseName) + +resource "google_spanner_database" "basic" { + instance = google_spanner_instance.basic.name + name = "%s_spangres" + deletion_protection = false +} +`, instanceName, instanceName, databaseName, databaseName) } func testAccSpannerDatabase_basicUpdate(instanceName, databaseName string) string { @@ -114,7 +120,19 @@ resource "google_spanner_database" "basic" { ] deletion_protection = false } -`, instanceName, instanceName, databaseName) + +resource "google_spanner_database" "basic" { + instance = google_spanner_instance.basic.name + name = "%s_spangres" + ddl = [ + "CREATE TABLE t1 (t1 bigint NOT NULL PRIMARY KEY)", + "CREATE TABLE t2 (t2 bigint NOT NULL PRIMARY KEY)", + "CREATE TABLE t3 (t3 bigint NOT NULL PRIMARY KEY)", + "CREATE TABLE t4 (t4 bigint NOT NULL PRIMARY KEY)", + ] + deletion_protection = false +} +`, instanceName, instanceName, databaseName, databaseName) } // Unit Tests for type spannerDatabaseId From 45723378bc15a2373394989e933ce2dfd6a5a378 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Wed, 9 Mar 2022 00:24:07 +0530 Subject: [PATCH 2/9] fix tests --- .../terraform/tests/resource_spanner_database_test.go.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index e20be229cc37..17d77aa9fd99 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -95,6 +95,7 @@ resource "google_spanner_database" "basic" { resource "google_spanner_database" "basic" { instance = google_spanner_instance.basic.name name = "%s_spangres" + database_dialect = "POSTGRESQL" deletion_protection = false } `, instanceName, instanceName, databaseName, databaseName) @@ -124,6 +125,7 @@ resource "google_spanner_database" "basic" { resource "google_spanner_database" "basic" { instance = google_spanner_instance.basic.name name = "%s_spangres" + database_dialect = "POSTGRESQL" ddl = [ "CREATE TABLE t1 (t1 bigint NOT NULL PRIMARY KEY)", "CREATE TABLE t2 (t2 bigint NOT NULL PRIMARY KEY)", From 15f8c93073fffc0571f263f400baaba843c35645 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Wed, 9 Mar 2022 10:48:27 +0530 Subject: [PATCH 3/9] fix tests --- .../resource_spanner_database_test.go.erb | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index 17d77aa9fd99..86997857a92c 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -35,6 +35,12 @@ func TestAccSpannerDatabase_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, }, + { + ResourceName: "google_spanner_database.basic_spangres", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, + }, { Config: testAccSpannerDatabase_basicUpdate(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( @@ -69,6 +75,33 @@ func TestAccSpannerDatabase_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, }, + { + ResourceName: "google_spanner_database.basic_spangres", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, + }, + { + ResourceName: "google_spanner_database.basic_spangres", + ImportStateId: fmt.Sprintf("projects/%s/instances/%s/databases/%s_spangres", project, instanceName, databaseName), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, + }, + { + ResourceName: "google_spanner_database.basic_spangres", + ImportStateId: fmt.Sprintf("instances/%s/databases/%s_spangres", instanceName, databaseName), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, + }, + { + ResourceName: "google_spanner_database.basic_spangres", + ImportStateId: fmt.Sprintf("%s/%s_spangres", instanceName, databaseName), + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, + }, }, }) } @@ -92,7 +125,7 @@ resource "google_spanner_database" "basic" { deletion_protection = false } -resource "google_spanner_database" "basic" { +resource "google_spanner_database" "basic_spangres" { instance = google_spanner_instance.basic.name name = "%s_spangres" database_dialect = "POSTGRESQL" @@ -122,7 +155,7 @@ resource "google_spanner_database" "basic" { deletion_protection = false } -resource "google_spanner_database" "basic" { +resource "google_spanner_database" "basic_spangres" { instance = google_spanner_instance.basic.name name = "%s_spangres" database_dialect = "POSTGRESQL" From 0aea37b240ad409938c2b9b07d74ca79b21d8f19 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Wed, 9 Mar 2022 11:56:54 +0530 Subject: [PATCH 4/9] fix database name when using POSTGRESQL dialect --- mmv1/templates/terraform/encoders/spanner_database.go.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mmv1/templates/terraform/encoders/spanner_database.go.erb b/mmv1/templates/terraform/encoders/spanner_database.go.erb index 6651f0d9e475..c88fb37463f9 100644 --- a/mmv1/templates/terraform/encoders/spanner_database.go.erb +++ b/mmv1/templates/terraform/encoders/spanner_database.go.erb @@ -1,4 +1,7 @@ obj["createStatement"] = fmt.Sprintf("CREATE DATABASE `%s`", obj["name"]) +if dialect, ok := obj["databaseDialect"]; ok && dialect == "POSTGRESQL" { + obj["createStatement"] = fmt.Sprintf("CREATE DATABASE %s", obj["name"]) +} delete(obj, "name") delete(obj, "instance") return obj, nil From 85a4b2c2d26526b32b0442f2f8c8efa92eec59a7 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Thu, 24 Mar 2022 23:45:56 +0530 Subject: [PATCH 5/9] use `default_from_api` for backward compatibility --- mmv1/products/spanner/terraform.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mmv1/products/spanner/terraform.yaml b/mmv1/products/spanner/terraform.yaml index facae6d37692..1f1675b271ba 100644 --- a/mmv1/products/spanner/terraform.yaml +++ b/mmv1/products/spanner/terraform.yaml @@ -63,6 +63,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides ignore_read: true state: !ruby/object:Overrides::Terraform::PropertyOverride exclude: false + databaseDialect: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true custom_code: !ruby/object:Provider::Terraform::CustomCode constants: 'templates/terraform/constants/spanner_database.go.erb' encoder: templates/terraform/encoders/spanner_database.go.erb From a95eb1a67222e620749055eecc93fc8ce5075af2 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Fri, 25 Mar 2022 21:54:27 +0530 Subject: [PATCH 6/9] incorporate requested changes --- mmv1/products/spanner/api.yaml | 6 +- mmv1/products/spanner/terraform.yaml | 2 +- .../resource_spanner_database_test.go.erb | 139 ++++++++++++------ 3 files changed, 99 insertions(+), 48 deletions(-) diff --git a/mmv1/products/spanner/api.yaml b/mmv1/products/spanner/api.yaml index b97087b2fe9b..70177a93fabd 100644 --- a/mmv1/products/spanner/api.yaml +++ b/mmv1/products/spanner/api.yaml @@ -213,12 +213,10 @@ objects: name: 'databaseDialect' description: | The dialect of the Cloud Spanner Database. - If it is not provided, "DATABASE_DIALECT_UNSPECIFIED" will be used, - which will create a Google Standard SQL database. + If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Note: Databases that are created with POSTGRESQL dialect do not support - extra DDL statements in the `CreateDatabase` call. We must therefore re-apply + extra DDL statements in the `CreateDatabase` call. You must therefore re-apply terraform with ddl on the same database after creation. values: - - :DATABASE_DIALECT_UNSPECIFIED - :GOOGLE_STANDARD_SQL - :POSTGRESQL \ No newline at end of file diff --git a/mmv1/products/spanner/terraform.yaml b/mmv1/products/spanner/terraform.yaml index 1f1675b271ba..670c3807d7b0 100644 --- a/mmv1/products/spanner/terraform.yaml +++ b/mmv1/products/spanner/terraform.yaml @@ -33,7 +33,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides for more information on lifecycle parameters. Note: Databases that are created with POSTGRESQL dialect do not support - extra DDL statements in the `CreateDatabase` call. We must therefore re-apply + extra DDL statements in the `CreateDatabase` call. You must therefore re-apply terraform with ddl on the same database after creation. examples: diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index 86997857a92c..04855b9b30fd 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -35,12 +35,6 @@ func TestAccSpannerDatabase_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, }, - { - ResourceName: "google_spanner_database.basic_spangres", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, - }, { Config: testAccSpannerDatabase_basicUpdate(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( @@ -75,7 +69,88 @@ func TestAccSpannerDatabase_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, }, + }, + }) +} + +func testAccSpannerDatabase_basic(instanceName, databaseName string) string { + return fmt.Sprintf(` +resource "google_spanner_instance" "basic" { + name = "%s" + config = "regional-us-central1" + display_name = "%s-display" + num_nodes = 1 +} + +resource "google_spanner_database" "basic" { + instance = google_spanner_instance.basic.name + name = "%s" + ddl = [ + "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)", + "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)", + ] + deletion_protection = false +} +`, instanceName, instanceName, databaseName) +} + +func testAccSpannerDatabase_basicUpdate(instanceName, databaseName string) string { + return fmt.Sprintf(` +resource "google_spanner_instance" "basic" { + name = "%s" + config = "regional-us-central1" + display_name = "%s-display" + num_nodes = 1 +} + +resource "google_spanner_database" "basic" { + instance = google_spanner_instance.basic.name + name = "%s" + ddl = [ + "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)", + "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)", + "CREATE TABLE t3 (t3 INT64 NOT NULL,) PRIMARY KEY(t3)", + "CREATE TABLE t4 (t4 INT64 NOT NULL,) PRIMARY KEY(t4)", + ] + deletion_protection = false +} +`, instanceName, instanceName, databaseName) +} + +func TestAccSpannerPGDatabase_basic(t *testing.T) { + t.Parallel() + + project := getTestProjectFromEnv() + rnd := randString(t, 10) + instanceName := fmt.Sprintf("tf-test-%s", rnd) + databaseName := fmt.Sprintf("tfgen_%s", rnd) + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckSpannerDatabaseDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccSpannerPGDatabase_basic(instanceName, databaseName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("google_spanner_database.basic", "state"), + ), + }, + { + // Test import with default Terraform ID + ResourceName: "google_spanner_database.basic_spangres", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, + }, + { + Config: testAccSpannerPGDatabase_basicUpdate(instanceName, databaseName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("google_spanner_database.basic", "state"), + ), + }, { + // Test import with default Terraform ID ResourceName: "google_spanner_database.basic_spangres", ImportState: true, ImportStateVerify: true, @@ -106,7 +181,7 @@ func TestAccSpannerDatabase_basic(t *testing.T) { }) } -func testAccSpannerDatabase_basic(instanceName, databaseName string) string { +func testAccSpannerPGDatabase_basic(instanceName, databaseName string) string { return fmt.Sprintf(` resource "google_spanner_instance" "basic" { name = "%s" @@ -115,26 +190,16 @@ resource "google_spanner_instance" "basic" { num_nodes = 1 } -resource "google_spanner_database" "basic" { +resource "google_spanner_database" "basic_spangres" { instance = google_spanner_instance.basic.name - name = "%s" - ddl = [ - "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)", - "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)", - ] + name = "%s_spangres" + database_dialect = "POSTGRESQL" deletion_protection = false } - -resource "google_spanner_database" "basic_spangres" { - instance = google_spanner_instance.basic.name - name = "%s_spangres" - database_dialect = "POSTGRESQL" - deletion_protection = false -} -`, instanceName, instanceName, databaseName, databaseName) +`, instanceName, instanceName, databaseName) } -func testAccSpannerDatabase_basicUpdate(instanceName, databaseName string) string { +func testAccSpannerPGDatabase_basicUpdate(instanceName, databaseName string) string { return fmt.Sprintf(` resource "google_spanner_instance" "basic" { name = "%s" @@ -143,31 +208,19 @@ resource "google_spanner_instance" "basic" { num_nodes = 1 } -resource "google_spanner_database" "basic" { +resource "google_spanner_database" "basic_spangres" { instance = google_spanner_instance.basic.name - name = "%s" + name = "%s_spangres" + database_dialect = "POSTGRESQL" ddl = [ - "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)", - "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)", - "CREATE TABLE t3 (t3 INT64 NOT NULL,) PRIMARY KEY(t3)", - "CREATE TABLE t4 (t4 INT64 NOT NULL,) PRIMARY KEY(t4)", + "CREATE TABLE t1 (t1 bigint NOT NULL PRIMARY KEY)", + "CREATE TABLE t2 (t2 bigint NOT NULL PRIMARY KEY)", + "CREATE TABLE t3 (t3 bigint NOT NULL PRIMARY KEY)", + "CREATE TABLE t4 (t4 bigint NOT NULL PRIMARY KEY)", ] deletion_protection = false } - -resource "google_spanner_database" "basic_spangres" { - instance = google_spanner_instance.basic.name - name = "%s_spangres" - database_dialect = "POSTGRESQL" - ddl = [ - "CREATE TABLE t1 (t1 bigint NOT NULL PRIMARY KEY)", - "CREATE TABLE t2 (t2 bigint NOT NULL PRIMARY KEY)", - "CREATE TABLE t3 (t3 bigint NOT NULL PRIMARY KEY)", - "CREATE TABLE t4 (t4 bigint NOT NULL PRIMARY KEY)", - ] - deletion_protection = false -} -`, instanceName, instanceName, databaseName, databaseName) +`, instanceName, instanceName, databaseName) } // Unit Tests for type spannerDatabaseId @@ -403,4 +456,4 @@ resource "google_project_service_identity" "ck_sa" { `, context) } -<% end -%> +<% end -%> \ No newline at end of file From e29385a936c78ce0b5c7c638a610f1ff08f12791 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Fri, 25 Mar 2022 22:56:11 +0530 Subject: [PATCH 7/9] fix tests --- .../terraform/tests/resource_spanner_database_test.go.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index 04855b9b30fd..dede789f99e5 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -133,7 +133,7 @@ func TestAccSpannerPGDatabase_basic(t *testing.T) { { Config: testAccSpannerPGDatabase_basic(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("google_spanner_database.basic", "state"), + resource.TestCheckResourceAttrSet("google_spanner_database.basic_spangres", "state"), ), }, { @@ -146,7 +146,7 @@ func TestAccSpannerPGDatabase_basic(t *testing.T) { { Config: testAccSpannerPGDatabase_basicUpdate(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("google_spanner_database.basic", "state"), + resource.TestCheckResourceAttrSet("google_spanner_database.basic_spangres", "state"), ), }, { From a01a629c06f381739c26efd6858c669283d5cb9b Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Mon, 28 Mar 2022 22:15:37 +0530 Subject: [PATCH 8/9] incorporate requested changes --- .../resource_spanner_database_test.go.erb | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index dede789f99e5..556c034b975b 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -117,7 +117,7 @@ resource "google_spanner_database" "basic" { `, instanceName, instanceName, databaseName) } -func TestAccSpannerPGDatabase_basic(t *testing.T) { +func TestAccSpannerDatabase_postgres(t *testing.T) { t.Parallel() project := getTestProjectFromEnv() @@ -131,7 +131,7 @@ func TestAccSpannerPGDatabase_basic(t *testing.T) { CheckDestroy: testAccCheckSpannerDatabaseDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccSpannerPGDatabase_basic(instanceName, databaseName), + Config: testAccSpannerDatabase_postgres(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("google_spanner_database.basic_spangres", "state"), ), @@ -144,7 +144,7 @@ func TestAccSpannerPGDatabase_basic(t *testing.T) { ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, }, { - Config: testAccSpannerPGDatabase_basicUpdate(instanceName, databaseName), + Config: testAccSpannerDatabase_postgresUpdate(instanceName, databaseName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("google_spanner_database.basic_spangres", "state"), ), @@ -156,32 +156,11 @@ func TestAccSpannerPGDatabase_basic(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, }, - { - ResourceName: "google_spanner_database.basic_spangres", - ImportStateId: fmt.Sprintf("projects/%s/instances/%s/databases/%s_spangres", project, instanceName, databaseName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, - }, - { - ResourceName: "google_spanner_database.basic_spangres", - ImportStateId: fmt.Sprintf("instances/%s/databases/%s_spangres", instanceName, databaseName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, - }, - { - ResourceName: "google_spanner_database.basic_spangres", - ImportStateId: fmt.Sprintf("%s/%s_spangres", instanceName, databaseName), - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"ddl", "deletion_protection"}, - }, }, }) } -func testAccSpannerPGDatabase_basic(instanceName, databaseName string) string { +func testAccSpannerDatabase_postgres(instanceName, databaseName string) string { return fmt.Sprintf(` resource "google_spanner_instance" "basic" { name = "%s" @@ -199,7 +178,7 @@ resource "google_spanner_database" "basic_spangres" { `, instanceName, instanceName, databaseName) } -func testAccSpannerPGDatabase_basicUpdate(instanceName, databaseName string) string { +func testAccSpannerDatabase_postgresUpdate(instanceName, databaseName string) string { return fmt.Sprintf(` resource "google_spanner_instance" "basic" { name = "%s" From efaf6a45c70febbffda72254265a392c9d17f35e Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Mon, 28 Mar 2022 22:31:28 +0530 Subject: [PATCH 9/9] remove unused code --- .../terraform/tests/resource_spanner_database_test.go.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb index 556c034b975b..87f4bf0abf58 100644 --- a/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_spanner_database_test.go.erb @@ -120,7 +120,6 @@ resource "google_spanner_database" "basic" { func TestAccSpannerDatabase_postgres(t *testing.T) { t.Parallel() - project := getTestProjectFromEnv() rnd := randString(t, 10) instanceName := fmt.Sprintf("tf-test-%s", rnd) databaseName := fmt.Sprintf("tfgen_%s", rnd)