This tool facilitates the migration of dbt Cloud resources between different instances/regions. It uses dbtcloud-terraforming to export existing configurations and terraform-provider-dbtcloud to apply them to the target instance.
- Terraform >= 1.0
- Access to both source and target dbt Cloud instances with admin privileges
- Service tokens for both source and target instances
- dbtcloud-terraforming tool
- terraform-provider-dbtcloud
Mac / Linux
brew tap hashicorp/tap && brew install hashicorp/tap/terraformWindows
choco install terraformMac / Linux
brew install dbt-labs/dbt-cli/dbtcloud-terraformingWindows
Check out the README for dbtcloud-terraforming for instructions on how to install for Windows.
First, set up environment variables for your source instance:
export DBT_CLOUD_HOST_URL="https://YOUR_SOURCE_REGION.getdbt.com/api"
export DBT_CLOUD_TOKEN="your_source_service_token"
export DBT_CLOUD_ACCOUNT_ID=your_source_account_idReview and modify resource_types.txt to specify which resources to export. See the dbtcloud-terraforming README for available resource types.
Then export the configuration:
./migrate.shOr if you haven't set environment variables, provide them as command line arguments:
./migrate.sh \
--source-host "https://cloud.getdbt.com/api" \
--source-token "your_source_service_token" \
--source-account-id "your_source_account_id"- Check the generated
target/resources.tffile- Environment references (
deferring_environment_id) are automatically updated to use Terraform resource references - Unsupported credential types are automatically set to
null - A backup of the original file is saved as
resources.tf.bak
- Environment references (
- Make any necessary adjustments:
- Modify or remove
credential_idvalues that were not automatically handled - Adjust any environment-specific settings
- Modify or remove
- Set up target instance configuration:
cd target
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your target instance details- Initialize Terraform:
terraform init- Preview changes:
terraform plan- Apply changes:
terraform apply- To remove resources:
terraform destroyFor more advanced Terraform usage, refer to the Terraform CLI documentation.
-
Verify Repository Connections:
- Reconnect Git repositories
- Verify branch configurations
- Test repository access
-
Update Credentials:
- Add repository / warehouse credentials
- Configure environment variables
- Set up service account tokens
-
Verify User Access:
- Ensure users have appropriate access
- Test SSO if applicable
- Verify group memberships
-
Test Jobs and Environments:
- Run test jobs
- Verify environment configurations
- Check scheduler settings
-
Credentials and Secrets:
- Repository credentials (SSH keys, tokens) must be manually recreated
- Service account tokens must be regenerated
- Environment variables containing secrets must be manually recreated
-
Project Data:
- Actual project data/artifacts are not migrated
- Job run history is not preserved
- Job artifacts and logs are not transferred
-
User Management:
- User accounts must exist in the target instance
- User permissions must be manually verified
- SSO configurations must be set up separately
# 1. Clone this repository
git clone https://github.com/dpguthrie/dbt-cloud-migration-tool
cd dbt-cloud-migration-tool
# 2. Install dependencies
brew tap hashicorp/tap && brew install hashicorp/tap/terraform
brew install dbt-labs/dbt-cli/dbtcloud-terraforming
# 3. Set up environment variables for source instance
export DBT_CLOUD_HOST_URL="https://cloud.getdbt.com/api"
export DBT_CLOUD_TOKEN="my_service_token"
export DBT_CLOUD_ACCOUNT_ID="12345"
# 4. Export source configuration
./migrate.sh
# 5. Configure target instance
cd target
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your target instance details
# 6. Apply changes using Terraform directly
terraform init
terraform plan
terraform apply-
API Tokens:
- Use service account tokens with limited scope
- Rotate tokens after migration
- Never commit tokens to version control
-
Sensitive Data:
- Manually handle all secrets and credentials
- Use environment variables for sensitive values
- Verify security settings in target instance
-
Access Control:
- Review and verify all permission assignments
- Implement principle of least privilege
- Document all access changes
-
Resource Conflicts:
- Ensure unique resource names in target instance
- Check for naming conflicts before migration
- Use resource mapping file for resolution
-
Connection Issues:
- Verify API access and tokens
- Check network connectivity
- Confirm region endpoints
-
Permission Errors:
- Verify admin access in both instances
- Check token permissions
- Review resource-specific access requirements
Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.