Code Monkey home page Code Monkey logo

dbt-avoid-chaos's Introduction

dbt-avoid-chaos

This repo can be used to configure dbt projects and automatically deploy them.

It is part of a talk made at Coalesce 2023 in London.

Overview of the demo

Overview

Some key design considerations:

  • All the dbt projects are managed in a single repository, different from the dbt repository itself
    • Another option would be to collocate the two, but keeping them separate makes it easier for the platform team to manage all projects from a single place
    • It is still possible to manage some Terraform configuration in the dbt project itself, like jobs, but it is a good idea to centralize the global best-practices and repo/warehouse connections. This also means that the dbt repo doesn't need any credential from git or the Data Warehouse and could use Terraform and dbt Cloud with a Service Token scoped to their project only
  • Each project uses its own remote state
    • Having all projects using the same state would allow us to perform changes across all projects with a single terraform plan/apply but it also would make all the projects depending on each other.
    • With multiple states, if 1 project has a problem and terraform plan fails for some reason, the other projects can still be updated

GH actions configured

  • on PR creation, if a project was created or modified under deployments, terraform plan is executed separately on every folder
    • if changes are identified in the deployments folder, the PR will be automatically updated with the output of terraform plan
  • on merge to main, if a project was created or modified under deployments, terraform apply -auto-approve is executed separately on every folder
  • it is possible to manually trigger a dbt destroy on a project in case we need to delete an existing project

Env vars / Secrets used

Secrets have been set in GitHub for

  • the Terraform backend (using Postgres in this example but could be used for any other backend)
  • the Terraform sensitive variables
    • they are all created as TF_VAR_terraform_var_name, like TF_VAR_DBT_TOKEN

dbt projects config

The current configuration leverages

Tips

To remove a project

  1. trigger a manual terraform destroy action for the project to be removed
  2. remove the files from the repo

In case the files have already been rmoved it is possible to trigger a terraform destroy on a previous branch/commit that still had the code.

dbt-avoid-chaos's People

Contributors

b-per avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.