Skip to content

Commit

Permalink
Merge pull request #251 from dbt-labs/muxing-terraform-plugin-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per authored Apr 21, 2024
2 parents 0f0fe0b + df18352 commit 40a0432
Show file tree
Hide file tree
Showing 117 changed files with 1,409 additions and 872 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

All notable changes to this project will be documented in this file.

## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.25...HEAD)
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.3.0...HEAD)

## [0.3.0](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.25...v0.3.0)

## Changes

- Implements muxing to allow both SDKv2 and Plugin Framework resources to work at the same time. This change a bit the internals but shouldn't have any regression.
- Move some resources / datasources to the plugin Framework
- Remove legacy `dbt_cloud_xxx` resources

## [0.2.25](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.24...v0.2.25)

Expand Down
12 changes: 7 additions & 5 deletions docs/data-sources/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "dbtcloud_notification Data Source - dbtcloud"
subcategory: ""
description: |-
Retrieve notification details
---

# dbtcloud_notification (Data Source)


Retrieve notification details

## Example Usage

Expand All @@ -23,14 +23,16 @@ data "dbtcloud_notification" "my_notification" {

### Required

- `notification_id` (Number) ID of the notification
- `notification_id` (Number) The ID of the notification

### Read-Only

- `external_email` (String) The external email to receive the notification
- `id` (String) The ID of this resource.
- `notification_type` (Number) Type of notification (1 = dbt Cloud user email (default): does not require an external_email ; 4 = external email: requires setting an external_email)
- `notification_type` (Number) Type of notification (1 = dbt Cloud user email (default): does not require an external_email ; 2 = Slack channel: requires `slack_channel_id` and `slack_channel_name` ; 4 = external email: requires setting an `external_email`)
- `on_cancel` (Set of Number) List of job IDs to trigger the webhook on cancel
- `on_failure` (Set of Number) List of job IDs to trigger the webhook on failure
- `on_success` (Set of Number) List of job IDs to trigger the webhook on success
- `slack_channel_id` (String) The ID of the Slack channel to receive the notification. It can be found at the bottom of the Slack channel settings
- `slack_channel_name` (String) The name of the slack channel
- `state` (Number) State of the notification (1 = active (default), 2 = inactive)
- `user_id` (Number) Internal dbt Cloud User ID. Must be the user_id for an existing user even if the notification is an external one
4 changes: 2 additions & 2 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "dbtcloud_user Data Source - dbtcloud"
subcategory: ""
description: |-
Retrieve user details
---

# dbtcloud_user (Data Source)


Retrieve user details

## Example Usage

Expand Down
56 changes: 7 additions & 49 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,19 @@ description: |-
# dbtcloud Provider

~> 🚧 IMPORTANT! 🚧
Since 0.2, resources and data sources are both available as `dbt_cloud_xxx` (legacy) and `dbtcloud_xxx` (following the Terraform convention).
Selecting one option or the other is done by modifying the `required_providers` configuration.
Since 0.3, only resources starting with `dbtcloud_xxx` are allowed. If you use the legacy `dbt_cloud_xxx` ones, you will have to stay on 0.2.x or move to the new resources.
Instruction on how to do it is available in the 0.2.x docs.

- `dbt_cloud_xxx` is kept in 0.2 for backward compatibility, but will be removed from version 0.3 onwards. Consider starting new projects with the `dbtcloud_xxx` naming convention
- `dbtcloud_xxx` follows the Terraform naming convention and is the long term convention for the dbt Cloud configuration

## Handling the move from `dbt_cloud_xxx` (legacy) to `dbtcloud_xxx`

As those are different resources, it is not possible to move existing resources using the `terraform state mv` command.

The options are:

- keep existing projects with `dbt_cloud_xxx` resources, and create new ones with `dbtcloud_xxx`
- or update the state file manually to change the resource names (this should work but it is possible to corrupt the state, be careful and keep a backup)
1. perform a `terraform apply` to apply the changes required to dbt Cloud
1. edit the resource configuration files changing resources from `dbt_cloud_xxx` to `dbtcloud_xxx`
1. edit `required_providers { dbt = {` and `provider "dbt"` to `required_providers { dbtcloud = {` and `provider "dbtcloud"`
1. pull the remote state with `terraform state pull > remote_state.tfstate` and keep a back up of the file
1. edit the state file to change the resource types from `dbt_cloud_xxx` to `dbtcloud_xxx`
1. push the state back with `terraform state push remote_state.tfstate`
1. perform a `terraform init -upgrade` to update the terraform provider
1. perform a `terraform plan` to check that no change is required, you can then delete the backup of the state



## Recommended - Example with ``dbtcloud_xxx`` resources, using the `dbtcloud` provider name
## Provider configuration

```terraform
terraform {
required_providers {
dbtcloud = {
source = "dbt-labs/dbtcloud"
version = "0.2.0"
version = "~> 0.3"
}
}
}
Expand All @@ -52,33 +32,11 @@ provider "dbtcloud" {
}
```

## Legacy - Example with `dbt_cloud_xxx` resources, using the `dbt` provider name

```terraform
terraform {
required_providers {
dbt = {
source = "dbt-labs/dbtcloud"
version = "0.2.0"
}
}
}
provider "dbt" {
account_id = var.dbt_cloud_account_id
token = var.dbt_cloud_token
host_url = "https://cloud.getdbt.com/api"
}
```

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

### Required

- `account_id` (Number) Account identifier for your dbt Cloud implementation. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_ACCOUNT_ID`
- `token` (String) API token for your dbt Cloud. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_TOKEN`

### Optional

- `host_url` (String) URL for your dbt Cloud deployment. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_HOST_URL` - Defaults to https://cloud.getdbt.com/api
- `account_id` (Number) Account identifier for your dbt Cloud implementation. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_ACCOUNT_ID`
- `host_url` (String) URL for your dbt Cloud deployment. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_HOST_URL` - Defaults to https://cloud.getdbt.com/api
- `token` (String, Sensitive) API token for your dbt Cloud. Instead of setting the parameter, you can set the environment variable `DBT_CLOUD_TOKEN`
6 changes: 3 additions & 3 deletions docs/resources/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
page_title: "dbtcloud_notification Resource - dbtcloud"
subcategory: ""
description: |-
Setup notifications on jobs success/failure to internal users, external email addresses or Slack channels
---

# dbtcloud_notification (Resource)



Setup notifications on jobs success/failure to internal users, external email addresses or Slack channels

## Example Usage

Expand Down Expand Up @@ -76,7 +76,7 @@ resource "dbtcloud_notification" "prod_job_slack_notifications" {

### Read-Only

- `id` (String) The ID of this resource.
- `id` (String) The ID of the notification

## Import

Expand Down
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
dbtcloud = {
source = "dbt-labs/dbtcloud"
version = "0.2.0"
version = "~> 0.3"
}
}
}
Expand Down
59 changes: 32 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,51 @@ go 1.21

require (
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.7.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.22.1
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-plugin-testing v1.7.0
github.com/samber/lo v1.39.0
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-hclog v1.6.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.5.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.1 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/hc-install v0.6.3 // indirect
github.com/hashicorp/hcl/v2 v2.20.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
github.com/hashicorp/terraform-exec v0.20.0 // indirect
github.com/hashicorp/terraform-json v0.21.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
Expand All @@ -57,17 +61,18 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
github.com/zclconf/go-cty v1.14.3 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
Loading

0 comments on commit 40a0432

Please sign in to comment.