Quick Start Guide¶
Get your dbt Cloud project set up with Terraform in under 5 minutes.
Prerequisites¶
Before you begin, make sure you have:
- Terraform >= 1.0 installed
- dbt Cloud account with admin access
- dbt Cloud API token (generate at Profile > API Access)
- Git repository with your dbt project
Step 1: Copy the Example¶
Start with the basic example as a template:
git clone https://github.com/trouze/terraform-dbtcloud-yaml.git
cd terraform-dbtcloud-yaml/examples/basic
# Or copy to your own directory
cp -r examples/basic ~/my-dbt-setup
cd ~/my-dbt-setup
The basic example includes:
basic/
├── main.tf # Terraform module call
├── variables.tf # Input variable definitions
├── dbt-config.yml # Your dbt Cloud configuration
├── .env.example # Credential template
└── .github/
└── workflows/
├── ci.yml # Plan on PR
└── cd.yml # Apply on merge
Step 2: Set Your Credentials¶
Credentials are passed via environment variables — never hardcoded. In CI/CD, set these as secrets in your platform (see CI/CD Guide). For local use:
Your .env should look like:
# Required
export TF_VAR_dbt_account_id=12345
export TF_VAR_dbt_token=dbtc_your_api_token
export TF_VAR_dbt_host_url=https://cloud.getdbt.com
# Environment credentials — keyed by "{project_key}_{env_key}"
export TF_VAR_environment_credentials='{
"analytics_prod": {
"credential_type": "databricks",
"token": "dapi...",
"catalog": "main",
"schema": "analytics"
}
}'
Where to find these values
- Account ID: Found in your dbt Cloud URL:
https://cloud.getdbt.com/accounts/{account_id}/ - API Token: Generate at https://cloud.getdbt.com/settings/profile — starts with
dbtc_ - Host URL:
https://cloud.getdbt.comfor US multi-tenant; see Environment Variables for other regions
Security
Never commit .env or terraform.tfvars to version control. Both are in .gitignore by default.
Step 3: Configure Your dbt Project¶
Edit dbt-config.yml with your project details:
projects:
- name: Analytics
key: analytics
repository:
remote_url: "your-org/your-repo" # GitHub: "org/repo", or full URL
github_installation_id: 1234567 # From GitHub App integration
environments:
- name: Production
key: prod
type: deployment
deployment_type: production
connection_key: databricks_prod # References global_connections[].key
credential:
credential_type: databricks
catalog: main
schema: analytics
jobs:
- name: Daily Build
key: daily_build
environment_key: prod # References environments[].key
execute_steps:
- dbt build
triggers:
schedule: true
schedule_type: every_day
schedule_hours: [6] # 6 AM UTC
connection_key
Instead of a raw numeric connection_id, environments reference connections by connection_key — matching global_connections[].key in the YAML. This keeps your config portable and readable.
Jobs at project level
Jobs are defined at the project level with an environment_key field, not nested inside environments. This makes them easier to read and reference by key for deferral.
See the YAML Schema for all available fields including global connections, service tokens, Snowflake credentials, scheduled jobs, and more.
Step 4: Initialize Terraform¶
You should see:
Initializing modules...
Downloading git::https://github.com/trouze/terraform-dbtcloud-yaml.git...
Terraform has been successfully initialized!
Step 5: Preview Changes¶
Always review what Terraform will create:
You'll see output like:
Plan: 5 to add, 0 to change, 0 to destroy.
+ dbtcloud_project.projects["analytics"]
+ dbtcloud_repository.repositories["analytics"]
+ dbtcloud_environment.environments["analytics_prod"]
+ dbtcloud_databricks_credential.credentials["analytics_prod"]
+ dbtcloud_job.jobs["analytics_daily_build"]
Step 6: Apply Configuration¶
Type yes when prompted. Terraform will create your dbt Cloud project, environments, credentials, and jobs.
Step 7: Verify in dbt Cloud¶
- Log into dbt Cloud
- Navigate to your account
- Confirm your project, environments, and jobs are configured correctly
Making Changes¶
After initial setup, all changes go through the same loop:
- Edit
dbt-config.yml - Run
terraform planto preview - Run
terraform applyto apply
What's Next?¶
-
YAML Schema
All configuration options with types, defaults, and examples
-
:material-github-box:{ .lg .middle } CI/CD Integration
Automate plan on PR and apply on merge
-
Environment Variables
Full credential variable reference
-
Troubleshooting
Common issues and solutions
You're all set!
Your dbt Cloud project is now managed as code. All changes are tracked in Git and deployed via Terraform.