From cb29789878064a79bb598a658dda3385557917f5 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Date: Mon, 2 Sep 2024 13:53:06 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=94=A7=20(auth.tf):=20Update=20type?= =?UTF-8?q?=20assignment=20formatting=20for=20DBX=5FTOKEN=20variable=20for?= =?UTF-8?q?=20consistency=20=E2=9C=A8=20(dbsql=5Fendpoint.tf):=20Add=20ran?= =?UTF-8?q?dom=20suffix=20to=20endpoint=20name=20for=20uniqueness=20?= =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(schema.auto.tfvars):=20Align=20TF=5FVAR?= =?UTF-8?q?=5FTEST=5FCATALOG=20and=20TF=5FVAR=5FTEST=5FSCHEMA=20assignment?= =?UTF-8?q?s=20for=20consistency=20=E2=99=BB=EF=B8=8F=20(schema.tf):=20Ref?= =?UTF-8?q?actor=20type=20and=20default=20assignments=20for=20TF=5FVAR=5FT?= =?UTF-8?q?EST=5FSCHEMA,=20TF=5FVAR=5FTEST=5FCATALOG,=20and=20schema=5Ffor?= =?UTF-8?q?ce=5Fdestroy=20variables=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/terraform/auth.tf | 2 +- src/test/terraform/dbsql_endpoint.tf | 12 ++++++++++-- src/test/terraform/schema.auto.tfvars | 4 ++-- src/test/terraform/schema.tf | 16 ++++++++-------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/test/terraform/auth.tf b/src/test/terraform/auth.tf index e70155f1..b79148b9 100644 --- a/src/test/terraform/auth.tf +++ b/src/test/terraform/auth.tf @@ -3,7 +3,7 @@ variable "DBX_HOST" { } variable "DBX_TOKEN" { - type = string + type = string } # Initialize the Databricks Terraform provider. diff --git a/src/test/terraform/dbsql_endpoint.tf b/src/test/terraform/dbsql_endpoint.tf index cb080d1b..a929d10f 100644 --- a/src/test/terraform/dbsql_endpoint.tf +++ b/src/test/terraform/dbsql_endpoint.tf @@ -1,8 +1,16 @@ +resource "random_string" "suffix" { + length = 8 + special = false + upper = false +} resource "databricks_sql_endpoint" "this" { - name = "Databricks Liquibase Test Harness Endpoint" + name = "Databricks Liquibase Test Harness Endpoint-${random_string.suffix.result}" cluster_size = "Small" max_num_clusters = 1 - warehouse_type = "PRO" + warehouse_type = "PRO" + lifecycle { + create_before_destroy = true + } } output "endpoint_url" { diff --git a/src/test/terraform/schema.auto.tfvars b/src/test/terraform/schema.auto.tfvars index 10dc8c37..734deddd 100644 --- a/src/test/terraform/schema.auto.tfvars +++ b/src/test/terraform/schema.auto.tfvars @@ -1,3 +1,3 @@ -TF_VAR_TEST_CATALOG = "main" -TF_VAR_TEST_SCHEMA = "liquibase_harness_test_ds" +TF_VAR_TEST_CATALOG = "main" +TF_VAR_TEST_SCHEMA = "liquibase_harness_test_ds" schema_force_destroy = true \ No newline at end of file diff --git a/src/test/terraform/schema.tf b/src/test/terraform/schema.tf index 5ffdb728..9810a776 100644 --- a/src/test/terraform/schema.tf +++ b/src/test/terraform/schema.tf @@ -1,25 +1,25 @@ variable "TF_VAR_TEST_SCHEMA" { description = "Name of Liquibase test harness database" - type = string - default = "liquibase_harness_test_ds" + type = string + default = "liquibase_harness_test_ds" } variable "TF_VAR_TEST_CATALOG" { description = "Catalog of liquibase testing database" - type = string - default = "main" + type = string + default = "main" } variable "schema_force_destroy" { - type = bool + type = bool default = true } resource "databricks_schema" "test_harness" { - catalog_name = var.TF_VAR_TEST_CATALOG - name = var.TF_VAR_TEST_SCHEMA - comment = "This database is for liquibase test harness" + catalog_name = var.TF_VAR_TEST_CATALOG + name = var.TF_VAR_TEST_SCHEMA + comment = "This database is for liquibase test harness" force_destroy = var.schema_force_destroy properties = { purpose = "testing" From 8d51e59da83b81187dbac49589c44ed6a94af5c5 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Date: Mon, 2 Sep 2024 14:14:01 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=A7=20(lth.yml):=20add=20terraform?= =?UTF-8?q?=20taint=20commands=20to=20target=20specific=20resources=20befo?= =?UTF-8?q?re=20applying=20changes=20for=20better=20control=20and=20accura?= =?UTF-8?q?cy=20=F0=9F=94=A7=20(dbsql=5Fendpoint.tf):=20remove=20random=20?= =?UTF-8?q?suffix=20generation=20for=20endpoint=20name=20to=20simplify=20a?= =?UTF-8?q?nd=20standardize=20naming=20convention?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lth.yml | 4 +++- src/test/terraform/dbsql_endpoint.tf | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lth.yml b/.github/workflows/lth.yml index 8b37fb38..02b61a53 100644 --- a/.github/workflows/lth.yml +++ b/.github/workflows/lth.yml @@ -41,7 +41,9 @@ jobs: - run: terraform plan working-directory: src/test/terraform - - run: terraform apply -auto-approve + - run: | + terraform taint databricks_sql_endpoint.this && terraform taint databricks_schema.test_harness + terraform apply -auto-approve working-directory: src/test/terraform - name: Collect Databricks Config diff --git a/src/test/terraform/dbsql_endpoint.tf b/src/test/terraform/dbsql_endpoint.tf index a929d10f..4a9798ee 100644 --- a/src/test/terraform/dbsql_endpoint.tf +++ b/src/test/terraform/dbsql_endpoint.tf @@ -1,16 +1,8 @@ -resource "random_string" "suffix" { - length = 8 - special = false - upper = false -} resource "databricks_sql_endpoint" "this" { - name = "Databricks Liquibase Test Harness Endpoint-${random_string.suffix.result}" + name = "Databricks Liquibase Test Harness Endpoint" cluster_size = "Small" max_num_clusters = 1 warehouse_type = "PRO" - lifecycle { - create_before_destroy = true - } } output "endpoint_url" { From 8944d6998d67965ea03cb43fba5e6244c3ef61c8 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Date: Mon, 2 Sep 2024 14:22:53 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A7=20(lth.yml):=20update=20terraf?= =?UTF-8?q?orm=20import=20command=20to=20import=20specific=20resource=20be?= =?UTF-8?q?fore=20tainting=20another=20resource=20for=20better=20resource?= =?UTF-8?q?=20management=20=F0=9F=94=A7=20(dbsql=5Fendpoint.tf):=20add=20r?= =?UTF-8?q?andom=20suffix=20to=20the=20name=20of=20the=20databricks=5Fsql?= =?UTF-8?q?=5Fendpoint=20resource=20to=20ensure=20uniqueness=20and=20impro?= =?UTF-8?q?ve=20resource=20identification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lth.yml | 3 ++- src/test/terraform/dbsql_endpoint.tf | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lth.yml b/.github/workflows/lth.yml index 02b61a53..4c3a5a23 100644 --- a/.github/workflows/lth.yml +++ b/.github/workflows/lth.yml @@ -42,7 +42,8 @@ jobs: working-directory: src/test/terraform - run: | - terraform taint databricks_sql_endpoint.this && terraform taint databricks_schema.test_harness + terraform import databricks_schema.test_harness main.liquibase_harness_test_ds + terraform taint databricks_schema.test_harness terraform apply -auto-approve working-directory: src/test/terraform diff --git a/src/test/terraform/dbsql_endpoint.tf b/src/test/terraform/dbsql_endpoint.tf index 4a9798ee..a929d10f 100644 --- a/src/test/terraform/dbsql_endpoint.tf +++ b/src/test/terraform/dbsql_endpoint.tf @@ -1,8 +1,16 @@ +resource "random_string" "suffix" { + length = 8 + special = false + upper = false +} resource "databricks_sql_endpoint" "this" { - name = "Databricks Liquibase Test Harness Endpoint" + name = "Databricks Liquibase Test Harness Endpoint-${random_string.suffix.result}" cluster_size = "Small" max_num_clusters = 1 warehouse_type = "PRO" + lifecycle { + create_before_destroy = true + } } output "endpoint_url" { From 2eced2ad3fd16ed283976466c24e9f67529426c0 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Date: Mon, 2 Sep 2024 14:26:00 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=A7=20(lth.yml):=20add=20'||=20tru?= =?UTF-8?q?e'=20to=20terraform=20import=20and=20terraform=20taint=20comman?= =?UTF-8?q?ds=20to=20prevent=20failing=20the=20workflow=20if=20the=20resou?= =?UTF-8?q?rces=20are=20already=20imported=20or=20tainted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lth.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lth.yml b/.github/workflows/lth.yml index 4c3a5a23..1dde40ca 100644 --- a/.github/workflows/lth.yml +++ b/.github/workflows/lth.yml @@ -42,8 +42,8 @@ jobs: working-directory: src/test/terraform - run: | - terraform import databricks_schema.test_harness main.liquibase_harness_test_ds - terraform taint databricks_schema.test_harness + terraform import databricks_schema.test_harness main.liquibase_harness_test_ds || true + terraform taint databricks_schema.test_harness || true terraform apply -auto-approve working-directory: src/test/terraform