{"id":19807318,"url":"https://github.com/dbt-labs/dbtcloud-terraforming","last_synced_at":"2026-02-04T10:51:57.384Z","repository":{"id":217456867,"uuid":"725600157","full_name":"dbt-labs/dbtcloud-terraforming","owner":"dbt-labs","description":"CLI tool to help importing existing dbt Cloud config to Terraform","archived":false,"fork":false,"pushed_at":"2025-04-25T09:54:26.000Z","size":219,"stargazers_count":21,"open_issues_count":4,"forks_count":0,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-27T07:32:26.430Z","etag":null,"topics":["dbt","dbt-cloud","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbt-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-30T13:40:58.000Z","updated_at":"2025-04-25T09:52:59.000Z","dependencies_parsed_at":"2024-06-28T15:03:30.968Z","dependency_job_id":"1244916b-fcf9-4604-865e-c6f4afcfcf5a","html_url":"https://github.com/dbt-labs/dbtcloud-terraforming","commit_stats":{"total_commits":86,"total_committers":1,"mean_commits":86.0,"dds":0.0,"last_synced_commit":"838ba8d9dfc7f4c86764e011b91a5d104e1aa626"},"previous_names":["dbt-labs/dbtcloud-terraforming"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbt-labs%2Fdbtcloud-terraforming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbt-labs%2Fdbtcloud-terraforming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbt-labs%2Fdbtcloud-terraforming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbt-labs%2Fdbtcloud-terraforming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbt-labs","download_url":"https://codeload.github.com/dbt-labs/dbtcloud-terraforming/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251840231,"owners_count":21652301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbt","dbt-cloud","terraform"],"created_at":"2024-11-12T09:10:07.794Z","updated_at":"2026-02-04T10:51:57.379Z","avatar_url":"https://github.com/dbt-labs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbt Cloud Terraforming\n\n`dbtcloud-terraforming` has been created to be used along with the [dbt Cloud Terraform provider](https://registry.terraform.io/providers/dbt-labs/dbtcloud/latest) maintained by dbt Labs.\n\nIt can be used to generate the relevant Terraform configuration files based on existing dbt Cloud configuration.\n\n```sh\ndbtcloud-terraforming is an application that allows dbt Cloud users\nto be able to adopt Terraform by giving them a feasible way to get\nall of their existing dbt Cloud configuration into Terraform.\n\nUsage:\n  dbtcloud-terraforming [command]\n\nAvailable Commands:\n  completion  Generate the autocompletion script for the specified shell\n  generate    Fetch resources from the dbt Cloud API and generate the respective Terraform stanzas\n  genimport   Generate Terraform resources configuration and import commands for dbt Cloud resources\n  help        Help about any command\n  import      Output `terraform import` compatible commands and/or import blocks (require terraform \u003e= 1.5) in order to import resources into state\n  interactive Interactive mode to configure and run dbtcloud-terraforming\n  version     Print the version number of dbtcloud-terraforming\n\nFlags:\n  -a, --account string                   Use specific account ID for commands. [env var: DBT_CLOUD_ACCOUNT_ID]\n      --exclude-resource-types strings   List of resource types you wish to exclude from the generation. To be used with --resource-types all\n  -h, --help                             help for dbtcloud-terraforming\n      --host-url string                  Host URL to use to query the API, includes the /api part. [env var: DBT_CLOUD_HOST_URL]\n      --linked-resource-types strings    List of resource types to make dependencies links to instead of using IDs. Can be set to 'all' for linking all resources\n      --modern-import-block              Whether to generate HCL import blocks for generated resources instead of terraform import compatible CLI commands. This is only compatible with Terraform 1.5+. (default true)\n  -o, --output string                    Output file path. If not specified, output is written to stdout\n      --parameterize-jobs                Whether to parameterize jobs. Default=false\n  -p, --projects ints                    Project IDs to limit the import for. Imports all projects if not set. [env var: DBT_CLOUD_PROJECTS]\n      --resource-types all               List of resource types you wish to generate. Use all to generate all resources\n      --terraform-binary-path string     Path to an existing Terraform binary (otherwise, one will be downloaded) [env var: DBT_CLOUD_TERRAFORM_BINARY_PATH]\n      --terraform-install-path string    Path to an initialized Terraform working directory [env var: DBT_CLOUD_TERRAFORM_INSTALL_PATH] (default \".\")\n  -t, --token string                     API Token. [env var: DBT_CLOUD_TOKEN]\n  -v, --verbose                          Specify verbose output (same as setting log level to debug)\n\nUse \"dbtcloud-terraforming [command] --help\" for more information about a command.\n```\n\nThis tool can be used to load existing dbt Cloud configuration into Terraform. Currently the following resources are supported:\n\n| Resource                                                  | Resource Scope | Generate Supported | Import Supported | Requires manual setup |\n| --------------------------------------------------------- | -------------- | ------------------ | ---------------- | --------------------- |\n| dbtcloud_bigquery_connection (use glob conn if possible)  | Project        | ✅                 | ✅               | 🔒                   |\n| dbtcloud_bigquery_credential                              | Project        | ✅                 | ✅               |                       |\n| dbtcloud_connection (use glob conn if possible)           | Project        | ✅                 | ✅               | 🔒*                  |\n| dbtcloud_databricks_credential                            | Project        | ✅                 | ✅               | 🔒                    |\n| dbtcloud_environment                                      | Project        | ✅                 | ✅               |                       |\n| dbtcloud_environment_variable                             | Project        | ✅                 | ✅               | 🔒*                  |\n| dbtcloud_environment_variable_job_override                | Project        |                    |                  |                       |\n| dbtcloud_extended_attributes(*)                           | Project        | ✅                 | ✅               |                       |\n| dbtcloud_fabric_connection                                | Project        |                    |                  |                       |\n| dbtcloud_fabric_credential                                | Project        |                    |                  | 🔒                   |\n| dbtcloud_global_connection                                | Account        | ✅                 | ✅               | 🔒*                   |\n| dbtcloud_group                                            | Account        | ✅                 | ✅               |                       |\n| dbtcloud_job                                              | Project        | ✅                 | ✅               |                       |\n| dbtcloud_license_map                                      | Account        |                    |                  |                       |\n| dbtcloud_notification                                     | Account        | ✅                 | ✅               |                       |\n| dbtcloud_postgres_credential                              | Project        |                    |                  | 🔒*                  |\n| dbtcloud_project                                          | Project        | ✅                 | ✅               |                       |\n| dbtcloud_project_artefacts (deprecated)                   | Project        | ❌                 | ❌               |                       |\n| dbtcloud_project_connection (deprecated)                  | Project        | ❌                 | ❌               |                       |\n| dbtcloud_project_repository                               | Project        | ✅                 | ✅               |                       |\n| dbtcloud_repository                                       | Project        | ✅                 | ✅               |                       |\n| dbtcloud_service_token                                    | Account        | ✅                 | ✅               |                      |\n| dbtcloud_snowflake_credential                             | Project        | ✅                 | ✅               | 🔒                   |\n| dbtcloud_user_groups                                      | Account        | ✅                 | ✅               |                       |\n| dbtcloud_webhook                                          | Account        | ✅                 | ✅               |                       |\n\n\n## How to use the tool\n\n### Installation\n\n#### All OSes\n\nDownload the executable for your platform [from the GitHUb releases page](https://github.com/dbt-labs/dbtcloud-terraforming/releases) and extract it.\nYou can then add it to your PATH and run it with `dbtcloud-terraforming` or run it based on its location (e.g. `./dbtcloud-terraforming`).\n\nTo update to the latest version, you can head back to the release page and download and extract the executable again.\n\nAlternatively, you can use [`eget`](https://github.com/zyedidia/eget) to more easily download the relevant executable.\n\n#### MacOS and Linux\n\nThe CLI can be installed with `brew`, running `brew install dbt-labs/dbt-cli/dbtcloud-terraforming`.\n\nTo update to the latest version, you can run `brew upgrade dbt-labs/dbt-cli/dbtcloud-terraforming`.\n\n### Connecting to dbt Cloud\n\nTo connect to dbt Cloud, you need to provide an API token and a dbt Cloud Account ID. If your account is not hosted on cloud.getdbt.com you will also need to provide the relevant API endpoint.\n\n- token: can be set in the CLI with `--token` or `-t` ; or setting up the env var `DBT_CLOUD_TOKEN`\n- account id: can be set in the CLI with `--account` or `-a` ; or setting up the env var `DBT_CLOUD_ACCOUNT_ID`\n- API Host URL: can be set in the CLI with `--host-url` or setting up the env var `DBT_CLOUD_HOST_URL`\n\nExample:\n\n```sh\nexport DBT_CLOUD_TOKEN=\u003ctoken\u003e\nexport DBT_CLOUD_ACCOUNT_ID=123\nexport DBT_CLOUD_HOST_URL=\"https://emea.dbt.com/api\"\n```\n\nor for Powershell\n\n```sh\n$Env:DBT_CLOUD_TOKEN = '\u003ctoken\u003e'\n$Env:DBT_CLOUD_ACCOUNT_ID = 123\n$Env:DBT_CLOUD_HOST_URL = 'https://emea.dbt.com/api'\n```\n\n### Executing the tool\n\n#### Pre-requisite\n\nBy default, the tool requires a file called `main.tf` with information about the dbt Cloud Terraform provider, in the current directory:\n\n```tf\nterraform {\n  required_providers {\n    dbtcloud = {\n      source = \"dbt-labs/dbtcloud\"\n    }\n  }\n}\n```\n\nIf you already have a file defining the provider, you can point `dbtcloud-terraforming` to it via the flag `--terraform-install-path`\n\n#### Running the different commands\n\nInstall the tool and run commands like below:\n\nTo run it in \"interactive\" mode and be prompted for the different options available\n```sh\ndbtcloud-terraforming interactive\n```\n\nTo generate the config\n\n```sh\ndbtcloud-terraforming generate --resource-types dbtcloud_project,dbtcloud_environment,dbtcloud_job --linked-resource-types dbtcloud_project,dbtcloud_environment\n```\n\nTo generate the import blocks\n\n```sh\ndbtcloud-terraforming import --resource-types dbtcloud_project,dbtcloud_environment,dbtcloud_job --modern-import-block\n```\n\nTo generate both\n\n```sh\ndbtcloud-terraforming genimport --resource-types all \n```\n\nOnce both of the outputs are generated, you can copy paste them in a terraform file having the `dbtcloud` provider already set up and you can run a `terraform plan`.\nYou should see that all the resources are going to be imported and that no change will be triggered.\n\nThe different `resource_types` that can be used are the ones from the table above. They are a subset of the resources available in the dbt Cloud Terraform provider.\nGenerating and importing multiple resource types at once is possible by separating them with `,`\n\n### Selecting specific projects\n\nBy default, the tool loads all projects but we can restrict the projects to focus on by selecting `--projects 123,456,789` with `123`, `456` and `789` being the projects we want to load in Terraform\n\n### Linking resources in the configuration\n\nWhen generating the configuration, if `--linked-resource-types` is not set for any resource, all the existing IDs (Project ID, Environment ID etc...) will be stored in the config as IDs.\n\nThis is OK to load the configuration in Terraform, but it also means that if those projects change on the dbt Cloud side, Terraform will start failing.\nAdditionally, if a project is getting deleted for example, Terraform won't understand the impact to other objects, like environments, and you will start seeing errors.\n\nSetting up `--linked-resource-types` with the resource types you want to link will \"link\" resources together, like in a typical Terraform configuration.\n\nWith this example:\n\n```sh\ndbtcloud-terraforming generate --resource-types dbtcloud_project,dbtcloud_environment,dbtcloud_job --linked-resource-types dbtcloud_project,dbtcloud_environment\n```\n\n- the dbt Cloud environment resources will be linked to the project\n- and the dbt Cloud jobs will be linked to both their relevant project and environment\n\nThis can be especially useful if you want to replicate an existing project. To do so, you can generate all the config *without* importing it. You could change the name of a project, and after running a `terraform apply` all the objects will be newly created, replicating your existing config in another project.\n\n## Contributing\n\nCurrently, the best way to contribute is to raise bugs/feature requests as GitHub issues.\n\n## Credits\n\nA big part of this tool has been inspired from the Cloudflare library [cf-terraforming](https://github.com/cloudflare/cf-terraforming/tree/master)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbt-labs%2Fdbtcloud-terraforming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbt-labs%2Fdbtcloud-terraforming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbt-labs%2Fdbtcloud-terraforming/lists"}