class: title, center, middle # Deploying your dbt project --- # We've built our first models... now what? -- - How will our team members access them? They are currently in a schema named `dbt_jbloggs` -- - What happens if our underlying data gets updated? (It should!) -- - What happens if we add new models, or change existing ones? --- # Solution: -- - Run dbt on a schedule - Use a "trusted" schema for this run Also known as: - Running dbt in production - Deploying your dbt project ---
Deployment | Focus
Understand why you need to deploy your dbt project
List some considerations when deploying your project
List some options for deploying your dbt project
Deploy your dbt project with dbt Cloud
--- # Considerations Does your production run: * Use the latest version of your dbt project? → **continuous deployment** * Use the correct dbt version for your project? * Have monitoring and alerting if something goes wrong? * Have a way to debug failures? * Have a secure access model? * Build & test your modified code every time you want to merge changes? → **continuous integration** * Have a secure way to host your project documentation? --- # Deployment with dbt Cloud The scheduler in dbt Cloud is purpose built for running dbt jobs on a schedule. - ✅ Always pulls the latest version of your project - ✅ Easy to build on Pull Request (and tear down the schema afterwards) - ✅ Easy to generate and share documentation with users - ✅ Secure access model - ✅ Email and Slack notifications if something goes wrong, with rich logs - ✅ Persist run artifacts for later comparison and analysis --- # Scheduling a run in dbt Cloud You'll need: - A deployment environment - A job, which includes: - Commands - A schedule [Docs](https://docs.getdbt.com/docs/dbt-cloud/cloud-quickstart#create-a-new-job) ??? [teacher notes] * there are two different types of environments: a deployment and a development. * we've all been working in our own development environments, you each only have one. * everyone in the project shares the same deployment environments. You can have as many as you need. * jobs are built in a specific deployment environment. --- # The commands you should run as part of your dbt job #### At a minimum: - `dbt build` #### Additionally: - `Generate docs on run` - `Run source freshness` ---
??? - This is what your Home Dashboard will look like once you have jobs running in Production. - You'll see successes, errors, etc. and you can click through each invocation of a job for more information. --
demo
??? Demo Time: - walk through development environment - add deployment environment - create a new job - run job - set up notifications for a job - create a slim CI job - mention environment variables and injecting logic into your SQL with jinja if blocks --- # Additional strategies Recommended: - Separate "slim" CI job — fast runs, clear notifications - Weekly full refresh job — more on this later! Seen in the wild: - Separate jobs for different parts of your project - Blue/green deploys ([article](https://discourse.getdbt.com/t/performing-a-blue-green-deploy-of-your-dbt-project-on-snowflake/1349)) - Cloning from prod on CI runs (Snowflake only) --- class: subtitle # Knowledge check You should be able to: - Explain why you need to deploy your dbt project - List some considerations when deploying your project - List some options for deploying your dbt project - Deploy your dbt project with dbt Cloud --- # Resources * [Deploy with dbt Cloud](https://docs.getdbt.com/docs/deploy/deployments) * [Selection Syntax](https://docs.getdbt.com/reference/node-selection/syntax) * [Model Timing](https://docs.getdbt.com/docs/deploy/dbt-cloud-job#model-timing) * [Job Notifications](https://docs.getdbt.com/docs/deploy/job-notifications) --- class: subtitle #Zoom Out
dbt Learn Norms
Why dbt?
Modeling
Sources
Docs
Deployment