From 28aafc4ffdd0f7b048caf7d1f7270c37cd496a11 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:02:03 +0100 Subject: [PATCH 1/5] Update docs --- README.md | 4 ++++ docs/guides/3_importing_existing_configuration.md | 10 ++++++++++ docs/resources/databricks_credential.md | 4 ++-- .../dbtcloud_databricks_credential/resource.tf | 4 ++-- guides/3_importing_existing_configuration.md | 10 ++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 docs/guides/3_importing_existing_configuration.md create mode 100644 guides/3_importing_existing_configuration.md diff --git a/README.md b/README.md index f20327ea..acb48c9b 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,10 @@ The provider documentation is directly available [on the Terraform Registry](htt - Under [Guides](https://registry.terraform.io/providers/dbt-labs/dbtcloud/latest/docs/guides/1_getting_started), you will find a simple example of how to use the provider - Each resource ([example for jobs](https://registry.terraform.io/providers/dbt-labs/dbtcloud/latest/docs/resources/job)) has some usage examples and contains the list of parameters available +## Importing existing dbt Cloud configuration + +The CLI [dbtcloud-terraforming](https://github.com/dbt-labs/dbtcloud-terraforming) can be used to generate the Terraform configuration and import statements based on your existing dbt Cloud configuration. + ## Running Acceptance Tests Currently, acceptance tests, run via `make test-acceptance` must be done on your diff --git a/docs/guides/3_importing_existing_configuration.md b/docs/guides/3_importing_existing_configuration.md new file mode 100644 index 00000000..3c88a33d --- /dev/null +++ b/docs/guides/3_importing_existing_configuration.md @@ -0,0 +1,10 @@ +--- +page_title: "3. Importing existing configuration" +subcategory: "" +--- + +# 3. Importing existing configuration" + +The [CLI dbtcloud-terraforming](https://github.com/dbt-labs/dbtcloud-terraforming) can be used to generate the Terraform configuration files as well as import statements for existing dbt Cloud configuration. + +This tool can then be used to either start managing the dbt Cloud configuration in Terraform or to replicate objects (jobs for example) between different projects or environments. \ No newline at end of file diff --git a/docs/resources/databricks_credential.md b/docs/resources/databricks_credential.md index 141a4b35..ac28f933 100644 --- a/docs/resources/databricks_credential.md +++ b/docs/resources/databricks_credential.md @@ -20,7 +20,7 @@ description: |- # when using the Databricks adapter resource "dbtcloud_databricks_credential" "my_databricks_cred" { project_id = dbtcloud_project.dbt_project.id - adapter_id = 123 + adapter_id = dbtcloud_connection.my_databricks_connection.adapter_id target_name = "prod" token = "abcdefgh" schema = "my_schema" @@ -30,7 +30,7 @@ resource "dbtcloud_databricks_credential" "my_databricks_cred" { # when using the Spark adapter resource "dbtcloud_databricks_credential" "my_spark_cred" { project_id = dbtcloud_project.dbt_project.id - adapter_id = 456 + adapter_id = dbtcloud_connection.my_databricks_connection.adapter_id target_name = "prod" token = "abcdefgh" schema = "my_schema" diff --git a/examples/resources/dbtcloud_databricks_credential/resource.tf b/examples/resources/dbtcloud_databricks_credential/resource.tf index bac0d261..ead164b5 100644 --- a/examples/resources/dbtcloud_databricks_credential/resource.tf +++ b/examples/resources/dbtcloud_databricks_credential/resource.tf @@ -5,7 +5,7 @@ # when using the Databricks adapter resource "dbtcloud_databricks_credential" "my_databricks_cred" { project_id = dbtcloud_project.dbt_project.id - adapter_id = 123 + adapter_id = dbtcloud_connection.my_databricks_connection.adapter_id target_name = "prod" token = "abcdefgh" schema = "my_schema" @@ -15,7 +15,7 @@ resource "dbtcloud_databricks_credential" "my_databricks_cred" { # when using the Spark adapter resource "dbtcloud_databricks_credential" "my_spark_cred" { project_id = dbtcloud_project.dbt_project.id - adapter_id = 456 + adapter_id = dbtcloud_connection.my_databricks_connection.adapter_id target_name = "prod" token = "abcdefgh" schema = "my_schema" diff --git a/guides/3_importing_existing_configuration.md b/guides/3_importing_existing_configuration.md new file mode 100644 index 00000000..3c88a33d --- /dev/null +++ b/guides/3_importing_existing_configuration.md @@ -0,0 +1,10 @@ +--- +page_title: "3. Importing existing configuration" +subcategory: "" +--- + +# 3. Importing existing configuration" + +The [CLI dbtcloud-terraforming](https://github.com/dbt-labs/dbtcloud-terraforming) can be used to generate the Terraform configuration files as well as import statements for existing dbt Cloud configuration. + +This tool can then be used to either start managing the dbt Cloud configuration in Terraform or to replicate objects (jobs for example) between different projects or environments. \ No newline at end of file From 12b497824295a46755cb7d9f6b7014bbdea71c88 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:02:24 +0100 Subject: [PATCH 2/5] Add new permission to run jobs --- pkg/resources/group.go | 1 + pkg/resources/service_token.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/resources/group.go b/pkg/resources/group.go index 109e49dd..fe3c4160 100644 --- a/pkg/resources/group.go +++ b/pkg/resources/group.go @@ -23,6 +23,7 @@ var ( "git_admin", "team_admin", "job_admin", + "job_runner", "job_viewer", "analyst", "developer", diff --git a/pkg/resources/service_token.go b/pkg/resources/service_token.go index 4ddc4365..a5b6b5fa 100644 --- a/pkg/resources/service_token.go +++ b/pkg/resources/service_token.go @@ -23,6 +23,7 @@ var ( "git_admin", "team_admin", "job_admin", + "job_runner", "job_viewer", "analyst", "developer", From ce5fbf364a5ec7a1b65c06896034462bc4a10edf Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:03:16 +0100 Subject: [PATCH 3/5] Update Changelog for the new release --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dce732e..66ed988d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,18 @@ All notable changes to this project will be documented in this file. -## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.18...HEAD) +## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.19...HEAD) + + +## [0.2.18](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.18...v0.2.19) + +## Changes + +- Update permissions allowed for groups and token to include `job_runner` + +## Documentations + +- Add guide on `dbtcloud-terraforming` to import existing resources ## [0.2.18](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.17...v0.2.18) From f7f43fe5eb171f46c1b6d928dff0182254f2bfe3 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:36:47 +0100 Subject: [PATCH 4/5] Update test to resolving URL --- pkg/resources/fabric_connection_acceptance_test.go | 2 +- pkg/resources/fabric_credential_acceptance_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/resources/fabric_connection_acceptance_test.go b/pkg/resources/fabric_connection_acceptance_test.go index 2069a249..af6d699b 100644 --- a/pkg/resources/fabric_connection_acceptance_test.go +++ b/pkg/resources/fabric_connection_acceptance_test.go @@ -18,7 +18,7 @@ func TestAccDbtCloudFabricConnectionResource(t *testing.T) { connectionName2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) projectName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) database := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) - server := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + server := "example.com" port := 1337 resource.Test(t, resource.TestCase{ diff --git a/pkg/resources/fabric_credential_acceptance_test.go b/pkg/resources/fabric_credential_acceptance_test.go index 47de1d91..fa446789 100644 --- a/pkg/resources/fabric_credential_acceptance_test.go +++ b/pkg/resources/fabric_credential_acceptance_test.go @@ -99,7 +99,7 @@ resource "dbtcloud_fabric_connection" "fabric" { project_id = dbtcloud_project.test_project.id name = "Fabric" database = "testdb" - server = "testserver" + server = "example.com" port = 1234 } From 92b9852519febadbe6ae7154fa5c8191c1b7fdd7 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:42:14 +0100 Subject: [PATCH 5/5] Fix CI test --- pkg/resources/fabric_credential_acceptance_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/resources/fabric_credential_acceptance_test.go b/pkg/resources/fabric_credential_acceptance_test.go index fa446789..a900cc23 100644 --- a/pkg/resources/fabric_credential_acceptance_test.go +++ b/pkg/resources/fabric_credential_acceptance_test.go @@ -126,7 +126,7 @@ resource "dbtcloud_fabric_connection" "fabric" { project_id = dbtcloud_project.test_project.id name = "Fabric" database = "testdb" - server = "testserver" + server = "example.com" port = 1234 }