This repository contains demo code showcasing various options for hosting dbt (data build tool) documentation.
To generate and serve dbt docs locally, follow these simple steps:
-
Generate the Documentation: Open your terminal or command prompt and run the following command to generate the dbt documentation:
dbt docs generateThis command will create the necessary documentation files based on your dbt project.
-
Serve the Documentation: After generating the documentation, use the following command to serve it locally:
dbt docs serveBy default, the documentation will be served on port 8080. To specify a custom port, use:
dbt docs serve --port 3000This will serve the documentation on port 3000 (replace "3000" with any port of your choice).
-
View the Documentation: Open your web browser and navigate to http://localhost:8080/ (or your custom port) to access and view your dbt documentation.
That's it! Now you have your dbt documentation generated and served locally for easy access and review.
Here are several user-friendly hosting options for static websites like dbt docs:
The simplest and most straightforward option. It comes with no extra cost, but there's a limitation: sites hosted on Github Pages will be public in the free tier. For private access and authentication setup, an enterprise tier is required.
A powerful serverless platform with an intuitive git-based workflow. Netlify allows you to host static websites with ease. This is simple as well but ranked below Github Pages only because it sits outside the GitHub ecosystem.
A cost-effective option that offers the ability to add basic authentication for restricted access. S3 (Simple Storage Service) provides reliable storage for your static content, and CloudFront serves as a content delivery network for faster and more efficient distribution.
A robust enterprise solution that leverages your existing Microsoft identity system. This option allows you to authenticate users with their Microsoft Entra ID (formerly Azure AD) credentials, making it ideal for organizations already using Microsoft services. The implementation uses Lambda@Edge for authentication at the edge, providing a seamless and secure user experience without requiring server-side components.
See the cloudfront-microsoft-sso module for implementation details.
Another comprehensive option that provides the ability to let users sign up for access. In addition to S3 and CloudFront, Amazon Cognito is used to manage user identities and authentication. This setup allows you to control who can access your dbt docs by creating user pools and defining user sign-up and sign-in processes.
To deploy your dbt docs website, follow these steps:
-
Configure AWS Credentials: Run the following command to set up your AWS CLI credentials profile for Terraform to use. Replace
terraformwith your desired profile name if you have multiple profiles.aws configure --profile terraform -
Initialize Terraform: Initialize Terraform in the project directory using the following command:
terraform init -
Format Terraform Configuration: Ensure that your Terraform configuration files are properly formatted for consistency:
terraform fmt -recursive -
Deploy the Infrastructure: Apply the Terraform configuration to deploy your infrastructure:
terraform apply
Here are some useful references and resources related to hosting dbt docs and implementing authentication:
- AWS Static Website Hosting with Cognito and S3
- CloudFront Authorization at Edge (AWS Samples GitHub)
- Authorization Lambda@Edge (AWS Samples GitHub)
- Cognito Auth Example (sashee GitHub)
- Terraform AWS Lambda@Edge Cognito Authentication (disney GitHub)
- Validate User Email Domain AWS Cognito
- Microsoft Entra ID Documentation