From c7561ad346cf163f918fa3f3376340dfc3ecd104 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:01:15 +0200 Subject: [PATCH 1/4] Update possible env types in docs --- docs/resources/environment.md | 2 +- pkg/sdkv2/resources/environment.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/environment.md b/docs/resources/environment.md index c29e6f80..9a3b3c2e 100644 --- a/docs/resources/environment.md +++ b/docs/resources/environment.md @@ -55,7 +55,7 @@ resource "dbtcloud_environment" "dev_environment" { - `credential_id` (Number) Credential ID to create the environment with. A credential is not required for development environments but is required for deployment environments - `custom_branch` (String) Which custom branch to use in this environment -- `deployment_type` (String) The type of environment. Only valid for environments of type 'deployment' and for now can only be empty or set to 'production' +- `deployment_type` (String) The type of environment. Only valid for environments of type 'deployment' and for now can only be 'production', 'staging' or left empty for generic environments - `extended_attributes_id` (Number) ID of the extended attributes for the environment - `is_active` (Boolean) Whether the environment is active - `use_custom_branch` (Boolean) Whether to use a custom git branch in this environment diff --git a/pkg/sdkv2/resources/environment.go b/pkg/sdkv2/resources/environment.go index 8ea04630..3ce31e88 100644 --- a/pkg/sdkv2/resources/environment.go +++ b/pkg/sdkv2/resources/environment.go @@ -86,7 +86,7 @@ func ResourceEnvironment() *schema.Resource { Type: schema.TypeString, Optional: true, Default: "", - Description: "The type of environment. Only valid for environments of type 'deployment' and for now can only be empty or set to 'production'", + Description: "The type of environment. Only valid for environments of type 'deployment' and for now can only be 'production', 'staging' or left empty for generic environments", }, "environment_id": &schema.Schema{ Type: schema.TypeInt, From 03f4b8b74a313583cabcfa9767e0337e475b3ca9 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:01:39 +0200 Subject: [PATCH 2/4] Fix typo in BQ connections --- docs/resources/bigquery_connection.md | 2 +- examples/resources/dbtcloud_bigquery_connection/resource.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/bigquery_connection.md b/docs/resources/bigquery_connection.md index 99985b63..69eb62bc 100644 --- a/docs/resources/bigquery_connection.md +++ b/docs/resources/bigquery_connection.md @@ -48,7 +48,7 @@ resource "dbtcloud_bigquery_connection" "my_connection_with_oauth" { auth_provider_x509_cert_url = "my_auth_provider_x509_cert_url" client_x509_cert_url = "my_client_x509_cert_url" retries = 3 - appplication_id = "oauth_application_id" + application_id = "oauth_application_id" application_secret = "oauth_secret_id" } ``` diff --git a/examples/resources/dbtcloud_bigquery_connection/resource.tf b/examples/resources/dbtcloud_bigquery_connection/resource.tf index 11d40b2d..ca3c02dc 100644 --- a/examples/resources/dbtcloud_bigquery_connection/resource.tf +++ b/examples/resources/dbtcloud_bigquery_connection/resource.tf @@ -33,6 +33,6 @@ resource "dbtcloud_bigquery_connection" "my_connection_with_oauth" { auth_provider_x509_cert_url = "my_auth_provider_x509_cert_url" client_x509_cert_url = "my_client_x509_cert_url" retries = 3 - appplication_id = "oauth_application_id" + application_id = "oauth_application_id" application_secret = "oauth_secret_id" } From d043de482b3d04303ed5d1569eaa2d69153f8cd4 Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:01:53 +0200 Subject: [PATCH 3/4] Force new connection when project changes --- pkg/sdkv2/resources/bigquery_connection.go | 25 ++++++++++++++++++---- pkg/sdkv2/resources/connection.go | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pkg/sdkv2/resources/bigquery_connection.go b/pkg/sdkv2/resources/bigquery_connection.go index 7886af5b..cbbe7d77 100644 --- a/pkg/sdkv2/resources/bigquery_connection.go +++ b/pkg/sdkv2/resources/bigquery_connection.go @@ -39,6 +39,7 @@ func ResourceBigQueryConnection() *schema.Resource { "project_id": &schema.Schema{ Type: schema.TypeInt, Required: true, + ForceNew: true, Description: "Project ID to create the connection in", }, "name": &schema.Schema{ @@ -172,7 +173,11 @@ func ResourceBigQueryConnection() *schema.Resource { } } -func resourceBigQueryConnectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceBigQueryConnectionCreate( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { c := m.(*dbt_cloud.Client) var diags diag.Diagnostics @@ -292,7 +297,11 @@ func resourceBigQueryConnectionCreate(ctx context.Context, d *schema.ResourceDat return diags } -func resourceBigQueryConnectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceBigQueryConnectionRead( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { c := m.(*dbt_cloud.Client) var diags diag.Diagnostics @@ -385,7 +394,11 @@ func resourceBigQueryConnectionRead(ctx context.Context, d *schema.ResourceData, return diags } -func resourceBigQueryConnectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceBigQueryConnectionUpdate( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { c := m.(*dbt_cloud.Client) projectIdString := strings.Split(d.Id(), dbt_cloud.ID_DELIMITER)[0] @@ -548,7 +561,11 @@ func resourceBigQueryConnectionUpdate(ctx context.Context, d *schema.ResourceDat return resourceBigQueryConnectionRead(ctx, d, m) } -func resourceBigQueryConnectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceBigQueryConnectionDelete( + ctx context.Context, + d *schema.ResourceData, + m interface{}, +) diag.Diagnostics { return resourceConnectionDelete(ctx, d, m) diff --git a/pkg/sdkv2/resources/connection.go b/pkg/sdkv2/resources/connection.go index 3c647e02..a6fc9302 100644 --- a/pkg/sdkv2/resources/connection.go +++ b/pkg/sdkv2/resources/connection.go @@ -52,6 +52,7 @@ func ResourceConnection() *schema.Resource { "project_id": &schema.Schema{ Type: schema.TypeInt, Required: true, + ForceNew: true, Description: "Project ID to create the connection in", }, "name": &schema.Schema{ From 7e397b2ac7c8dc278f970163efdef4027263d69b Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:04:42 +0200 Subject: [PATCH 4/4] Changelog for new release --- CHANGELOG.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f7b1a3..1e348e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,19 @@ All notable changes to this project will be documented in this file. -## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.7...HEAD) +## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.9...HEAD) + +## [0.3.9](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.8...v0.3.9) + +### Fixes + +- [#271](https://github.com/dbt-labs/terraform-provider-dbtcloud/issues/271) Force creation of a new connection when the project is changed or deleted + +### Docs + +- Fix typo in environment code example + +## [0.3.8](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.7...v0.3.8) ### Changes