Skip to content

Commit

Permalink
Merge pull request #312 from dbt-labs/release-0.3.20
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per authored Oct 28, 2024
2 parents e3971cb + 6f7e125 commit 1c2f342
Show file tree
Hide file tree
Showing 38 changed files with 918 additions and 60 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.19...HEAD)
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.20...HEAD)

# [0.3.20](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.19...v0.3.20)

### Changes

- [#305](https://github.com/dbt-labs/terraform-provider-dbtcloud/issues/305) - Add the resource `dbtcloud_lineage_integration` to setup auto-exposures in Tableau
- Add ability to provide a project description in `dbtcloud_project`
- Add ability to enable model query history in `dbtcloud_environment`

### Fixes

- [#309](https://github.com/dbt-labs/terraform-provider-dbtcloud/issues/309) - Fix the datasource `dbtcloud_global_connections` when PL is used in some connection

# [0.3.19](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.18...v0.3.19)

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Retrieve data for a single environment
- `custom_branch` (String) The custom branch name to use
- `dbt_version` (String) Version number of dbt to use in this environment.
- `deployment_type` (String) The type of deployment environment (currently 'production', 'staging' or empty)
- `enable_model_query_history` (Boolean) Whether model query history is on
- `extended_attributes_id` (Number) The ID of the extended attributes applied
- `name` (String) The name of the environment
- `type` (String) The type of environment (must be either development or deployment)
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Read-Only:
- `custom_branch` (String) The custom branch name to use
- `dbt_version` (String) Version number of dbt to use in this environment.
- `deployment_type` (String) The type of deployment environment (currently 'production', 'staging' or empty)
- `enable_model_query_history` (Boolean) Whether model query history is on
- `environment_id` (Number) The ID of the environment
- `extended_attributes_id` (Number) The ID of the extended attributes applied
- `name` (String) The name of the environment
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/global_connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ Read-Only:
- `is_ssh_tunnel_enabled` (Boolean)
- `name` (String) Connection name
- `oauth_configuration_id` (Number)
- `private_link_endpoint_id` (Number) Private Link Endpoint ID.
- `private_link_endpoint_id` (String) Private Link Endpoint ID.
- `updated_at` (String) When the connection was updated
1 change: 1 addition & 0 deletions docs/data-sources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ data "dbtcloud_project" "test_project" {

### Optional

- `description` (String) The description of the project
- `name` (String) Given name for project
- `project_id` (Number) ID of the project to represent

Expand Down
9 changes: 5 additions & 4 deletions docs/resources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ resource "dbtcloud_environment" "dev_environment" {
### Optional

- `connection_id` (Number) The ID of the connection to use (can be the `id` of a `dbtcloud_global_connection` or the `connection_id` of a legacy connection).
- At the moment, it is optional and the environment will use the connection set in `dbtcloud_project_connection` if `connection_id` is not set in this resource
- In future versions this field will become required, so it is recommended to set it from now on
- When configuring this field, it needs to be configured for all the environments of the project
- To avoid Terraform state issues, when using this field, the `dbtcloud_project_connection` resource should be removed from the project or you need to make sure that the `connection_id` is the same in `dbtcloud_project_connection` and in the `connection_id` of the Development environment of the project
- At the moment, it is optional and the environment will use the connection set in `dbtcloud_project_connection` if `connection_id` is not set in this resource
- In future versions this field will become required, so it is recommended to set it from now on
- When configuring this field, it needs to be configured for all the environments of the project
- To avoid Terraform state issues, when using this field, the `dbtcloud_project_connection` resource should be removed from the project or you need to make sure that the `connection_id` is the same in `dbtcloud_project_connection` and in the `connection_id` of the Development environment of the project
- `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
- `dbt_version` (String) Version number of dbt to use in this environment. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre` or `versionless`. Defaults to`versionless` if no version is provided
- `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
- `enable_model_query_history` (Boolean) Whether to enable model query history in this environment. As of Oct 2024, works only for Snowflake and BigQuery.
- `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
Expand Down
69 changes: 69 additions & 0 deletions docs/resources/lineage_integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
page_title: "dbtcloud_lineage_integration Resource - dbtcloud"
subcategory: ""
description: |-
Setup lineage integration for dbt Cloud to automatically fetch lineage from external BI tools in dbt Explorer. Currently supports Tableau.
This resource requires having an environment tagged as production already created for you project.
---

# dbtcloud_lineage_integration (Resource)


Setup lineage integration for dbt Cloud to automatically fetch lineage from external BI tools in dbt Explorer. Currently supports Tableau.

This resource requires having an environment tagged as production already created for you project.

## Example Usage

```terraform
// the resource can only be configured when a Prod environment has been set
// so, you might want to explicitly set the dependency on your Prod environment resource
resource "dbtcloud_lineage_integration" "my_lineage" {
project_id = dbtcloud_project.my_project.id
host = "my.host.com"
site_id = "mysiteid"
token_name = "my-token-name"
token = "my-sensitive-token"
depends_on = [dbtcloud_environment.my_prod_env]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `host` (String) The URL of the BI server (see docs for more details)
- `project_id` (Number) The dbt Cloud project ID for the integration
- `site_id` (String) The sitename for the collections of dashboards (see docs for more details)
- `token` (String, Sensitive) The secret token value to use to authenticate to the BI server
- `token_name` (String) The token to use to authenticate to the BI server

### Read-Only

- `id` (String) Combination of `project_id` and `lineage_integration_id`
- `lineage_integration_id` (Number) The ID of the lineage integration
- `name` (String) The integration type. Today only 'tableau' is supported

## Import

Import is supported using the following syntax:

```shell
# using import blocks (requires Terraform >= 1.5)
import {
to = dbtcloud_lineage_integration.my_lineage_integration
id = "projet_id:lineage_integration_id"
}

import {
to = dbtcloud_lineage_integration.my_lineage_integration
id = "123:4567"
}

# using the older import command
terraform import dbtcloud_lineage_integration.my_lineage_integration "projet_id:lineage_integration_id"
terraform import dbtcloud_lineage_integration.my_lineage_integration 123:4567
```
5 changes: 5 additions & 0 deletions docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ description: |-
resource "dbtcloud_project" "dbt_project" {
name = "Analytics"
}
resource "dbtcloud_project" "dbt_project_with_description" {
name = "Analytics with description"
description = "My awesome analytics project"
}
resource "dbtcloud_project" "dbt_project_with_subdir" {
name = "Analytics in Subdir"
Expand All @@ -33,6 +37,7 @@ resource "dbtcloud_project" "dbt_project_with_subdir" {
### Optional

- `dbt_project_subdirectory` (String) dbt project subdirectory path
- `description` (String) Description for the project. Will show in dbt Explorer.

### Read-Only

Expand Down
4 changes: 2 additions & 2 deletions docs/resources/project_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
page_title: "dbtcloud_project_connection Resource - dbtcloud"
subcategory: ""
description: |-
~> This resource is deprecated with the release of global connections and it will be removed in a future version of the provider. Going forward, please set the connection_id in the dbtcloud_environment resource instead.
---

# dbtcloud_project_connection (Resource)



~> This resource is deprecated with the release of global connections and it will be removed in a future version of the provider. Going forward, please set the `connection_id` in the `dbtcloud_environment` resource instead.

## Example Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/snowflake_credential.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description: |-

```terraform
resource "dbtcloud_snowflake_credential" "prod_credential" {
project_id = data.dbtcloud_project.dbt_project.id
project_id = dbtcloud_project.dbt_project.id
auth_type = "password"
num_threads = 16
schema = "SCHEMA"
Expand Down
14 changes: 14 additions & 0 deletions examples/resources/dbtcloud_lineage_integration/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# using import blocks (requires Terraform >= 1.5)
import {
to = dbtcloud_lineage_integration.my_lineage_integration
id = "projet_id:lineage_integration_id"
}

import {
to = dbtcloud_lineage_integration.my_lineage_integration
id = "123:4567"
}

# using the older import command
terraform import dbtcloud_lineage_integration.my_lineage_integration "projet_id:lineage_integration_id"
terraform import dbtcloud_lineage_integration.my_lineage_integration 123:4567
12 changes: 12 additions & 0 deletions examples/resources/dbtcloud_lineage_integration/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// the resource can only be configured when a Prod environment has been set
// so, you might want to explicitly set the dependency on your Prod environment resource

resource "dbtcloud_lineage_integration" "my_lineage" {
project_id = dbtcloud_project.my_project.id
host = "my.host.com"
site_id = "mysiteid"
token_name = "my-token-name"
token = "my-sensitive-token"

depends_on = [dbtcloud_environment.my_prod_env]
}
4 changes: 4 additions & 0 deletions examples/resources/dbtcloud_project/resource.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
resource "dbtcloud_project" "dbt_project" {
name = "Analytics"
}
resource "dbtcloud_project" "dbt_project_with_description" {
name = "Analytics with description"
description = "My awesome analytics project"
}

resource "dbtcloud_project" "dbt_project_with_subdir" {
name = "Analytics in Subdir"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "dbtcloud_snowflake_credential" "prod_credential" {
project_id = data.dbtcloud_project.dbt_project.id
project_id = dbtcloud_project.dbt_project.id
auth_type = "password"
num_threads = 16
schema = "SCHEMA"
Expand Down
17 changes: 10 additions & 7 deletions pkg/dbt_cloud/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Environment struct {
DeploymentType *string `json:"deployment_type,omitempty"`
ExtendedAttributesID *int `json:"extended_attributes_id,omitempty"`
ConnectionID *int `json:"connection_id,omitempty"`
EnableModelQueryHistory bool `json:"enable_model_query_history,omitempty"`
}

func (c *Client) GetEnvironment(projectId int, environmentId int) (*Environment, error) {
Expand Down Expand Up @@ -79,20 +80,22 @@ func (c *Client) CreateEnvironment(
deploymentType string,
extendedAttributesID int,
connectionID int,
enableModelQueryHistory bool,
) (*Environment, error) {
state := STATE_ACTIVE
if !isActive {
state = STATE_DELETED
}

newEnvironment := Environment{
State: state,
Account_Id: c.AccountID,
Project_Id: projectId,
Name: name,
Dbt_Version: dbtVersion,
Type: type_,
Use_Custom_Branch: useCustomBranch,
State: state,
Account_Id: c.AccountID,
Project_Id: projectId,
Name: name,
Dbt_Version: dbtVersion,
Type: type_,
Use_Custom_Branch: useCustomBranch,
EnableModelQueryHistory: enableModelQueryHistory,
}
if credentialId != 0 {
newEnvironment.Credential_Id = &credentialId
Expand Down
20 changes: 10 additions & 10 deletions pkg/dbt_cloud/global_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
)

type GlobalConnectionSummary struct {
ID int64 `json:"id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
AccountID int64 `json:"account_id"`
Name string `json:"name"`
AdapterVersion string `json:"adapter_version"`
PrivateLinkEndpointID *int64 `json:"private_link_endpoint_id"`
IsSSHTunnelEnabled bool `json:"is_ssh_tunnel_enabled"`
OauthConfigurationID *int64 `json:"oauth_configuration_id"`
EnvironmentCount int64 `json:"environment__count"`
ID int64 `json:"id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
AccountID int64 `json:"account_id"`
Name string `json:"name"`
AdapterVersion string `json:"adapter_version"`
PrivateLinkEndpointID *string `json:"private_link_endpoint_id"`
IsSSHTunnelEnabled bool `json:"is_ssh_tunnel_enabled"`
OauthConfigurationID *int64 `json:"oauth_configuration_id"`
EnvironmentCount int64 `json:"environment__count"`
}

func (c *Client) GetAllConnections() ([]GlobalConnectionSummary, error) {
Expand Down
Loading

0 comments on commit 1c2f342

Please sign in to comment.