# dbt

![dbt-logo.svg](https://assets.relyanceuat.xyz/images/docs/8684746142477/8683971799309.svg)
dbt (data build tool) enables analytics engineers to transform data in their warehouses by writing select statements. It helps data analysts transform data using simple select statements, effectively creating your entire transformation process with code.

In order to integrate dbt with Relyance AI you will need an **API Key** and **Subdomain**.

#### In dbt:

1. Create a **Personal Access Token** as per the DBT Labs guide [here](https://docs.getdbt.com/docs/dbt-cloud-apis/user-tokens). Use this token as your **API Key** in Relyance.
2. Copy the **Subdomain** from your browser URL. **Example**: If you see [https://acme.us1.dbt.com](https://acme.us1.dbt.com,) copy the portion between *https://* and *dbt.com.*

![dbtlabs-5.png](https://assets.relyanceuat.xyz/images/docs/8684746142477/32878255077901.png)

#### In the Relyance AI application:

1. Login to your Relyance account.
2. Navigate to the **Settings** Menu in the bottom left-hand side.
3. Select **Integrations**.
4. Click on the **vendor Integration** tab.
5. Find the **dbt** integration card and click it to open its connections.
6. Under **Authentication Method**, choose **Custom**.
8. Paste the **API Key** into its respective fields.

![dbtlabs-4.png](https://assets.relyanceuat.xyz/images/docs/8684746142477/32868857107469.png)

9. Additional Features:
    - Use the **Vendor Discovery** checkbox if you wish to run this integration with Vendor Discovery Enabled.
    - Select the **Enable Data Inspection** checkbox if you wish Relyance also to inspect the data. For more information on Relyance features, please refer to this help center article: [here](/docs/introduction-to-relyance-ai/integration-features/).

The **Authentication** step asks for:

- **API Key**: required; held as a secret.
- **Subdomain (Eg: abc123.us1)**: Account prefix. Can be found on docs: https://docs.getdbt.com/docs/cloud/about-cloud/access-regions-ip-addresses#accessing-your-account; optional.

10. Click **Authenticate**.
11. At this point, you should see the following result on the **vendor** Integrations page:

![dbtlabs-3.png](https://assets.relyanceuat.xyz/images/docs/8684746142477/32868847171213.png)

12. Congratulations, you are now connected to **dbt**.

<!-- failure-modes:begin (generated from the integration catalog; do not hand-edit) -->

## If the connection reports Connected but returns nothing

These are the ways this integration comes back empty without reporting an error. Generated from the integration catalog, so it tracks what the connection actually asks for.

1. **A credential rotated at the vendor is not picked up here.** **API Key** is stored when you save the connection, so regenerating the value at the vendor breaks the next scan until it is re-pasted here. Recording the expiry on the connection means Relyance warns you before it lapses.
2. **Check the address fields before suspecting the credentials.** **Subdomain (Eg: abc123.us1)** identifies which tenant, region or host to talk to. A wrong value there fails authentication and looks exactly like a bad secret.

<!-- failure-modes:end -->

<!-- terraform-examples:begin (generated from the integration catalog; do not hand-edit) -->

## Manage this integration with Terraform

Connections for this integration can be managed as code with the [Relyance Terraform provider](https://registry.terraform.io/providers/Relyance/relyance/latest). Non-secret fields go in `auth.params`; secret fields go in `auth.secrets_wo`, which is write-only — never stored in Terraform state. Rotate secrets by bumping `auth.secrets_wo_version`.

```hcl
resource "relyance_integration_connection" "dbtlabs" {
  vendor = "dbtlabs"
  name   = "<your connection name>"

  auth = {
    method = "api-key"
    params = {
      data_storage_location = "us"
    }
    # Secret fields are write-only: sent to Relyance, never stored in state.
    secrets_wo = {
      api_key = var.dbtlabs_api_key
    }
    secrets_wo_version = 1
  }

  scans = { "data-inspection" = { enabled = true } }
}
```

<!-- terraform-examples:end -->
