Skip to content

Commit d19a36c

Browse files
authored
changes to update the README for dbt docs (#34)
1 parent de5fbdd commit d19a36c

File tree

4 files changed

+165
-42
lines changed

4 files changed

+165
-42
lines changed

dbt-docs/README.md

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,71 @@
1-
- [Overview](#overview)
2-
- [How to Generate and Serve dbt Docs Locally](#how-to-generate-and-serve-dbt-docs-locally)
3-
- [Hosting Options](#hosting-options)
4-
- [Github Pages](#github-pages)
5-
- [Netlify](#netlify)
6-
- [S3 and CloudFront](#s3-and-cloudfront)
7-
- [S3, CloudFront, and Cognito](#s3-cloudfront-and-cognito)
8-
- [Deployment Steps](#deployment-steps)
9-
- [Reference](#reference)
1+
# dbt Docs Hosting Solutions
102

11-
# Overview
12-
This repository contains demo code showcasing how to host dbt(data build tool) docs.
3+
- [dbt Docs Hosting Solutions](#dbt-docs-hosting-solutions)
4+
- [Overview](#overview)
5+
- [How to Generate and Serve dbt Docs Locally](#how-to-generate-and-serve-dbt-docs-locally)
6+
- [Hosting Options](#hosting-options)
7+
- [Github Pages](#github-pages)
8+
- [Netlify](#netlify)
9+
- [S3 and CloudFront](#s3-and-cloudfront)
10+
- [S3, CloudFront, and Microsoft Entra ID SSO](#s3-cloudfront-and-microsoft-entra-id-sso)
11+
- [S3, CloudFront, and Cognito](#s3-cloudfront-and-cognito)
12+
- [Deployment Steps](#deployment-steps)
13+
- [Reference](#reference)
1314

14-
# How to Generate and Serve dbt Docs Locally
15+
## Overview
16+
This repository contains demo code showcasing various options for hosting dbt (data build tool) documentation.
17+
18+
## How to Generate and Serve dbt Docs Locally
1519

1620
To generate and serve dbt docs locally, follow these simple steps:
1721

18-
1. **Generate the Document:** Open your terminal or command prompt and run the following command to generate the dbt document:
22+
1. **Generate the Documentation:** Open your terminal or command prompt and run the following command to generate the dbt documentation:
1923

20-
`dbt docs generate`, This command will create the necessary documentation files based on your dbt project.
24+
```
25+
dbt docs generate
26+
```
27+
28+
This command will create the necessary documentation files based on your dbt project.
2129

22-
2. **Serve the Document:** After generating the documentation, use the following command to serve it locally:
30+
2. **Serve the Documentation:** After generating the documentation, use the following command to serve it locally:
31+
32+
```
33+
dbt docs serve
34+
```
35+
36+
By default, the documentation will be served on port 8080. To specify a custom port, use:
2337

24-
`dbt docs serve`. By default, the documentation will be served on port 8080. However, if you want to specify a custom port, you can use the following command `dbt docs serve --port 3000`. This will serve the documentation on port 3000 (you can replace "3000" with any port of your choice).
38+
```
39+
dbt docs serve --port 3000
40+
```
41+
42+
This will serve the documentation on port 3000 (replace "3000" with any port of your choice).
2543

26-
3. **View the dbt Document:** Open your web browser and navigate to [http://localhost:8080/](http://localhost:8080/) (or the custom port you specified) to access and view your dbt document.
44+
3. **View the Documentation:** Open your web browser and navigate to [http://localhost:8080/](http://localhost:8080/) (or your custom port) to access and view your dbt documentation.
2745

28-
That's it ! Now you have your dbt documentation generated and served locally for easy access and review.
46+
That's it! Now you have your dbt documentation generated and served locally for easy access and review.
2947

30-
# Hosting Options
31-
Here are some user-friendly hosting options for static websites like dbt docs:
48+
## Hosting Options
49+
Here are several user-friendly hosting options for static websites like dbt docs:
3250

33-
## Github Pages
51+
### Github Pages
3452
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.
3553

36-
## Netlify
37-
A powerful serverless platform with an intuitive git-based workflow. Netlify allows to host static websites with ease. This is simple as well but preferenced below github pages only because it sits outside github eco system.
54+
### Netlify
55+
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.
3856

39-
## S3 and CloudFront
57+
### S3 and CloudFront
4058
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.
4159

42-
## S3, CloudFront, and Cognito
43-
The most robust 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.
60+
### S3, CloudFront, and Microsoft Entra ID SSO
61+
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.
62+
63+
See the [cloudfront-microsoft-sso](./terraform/cloudfront-microsoft-sso/README.md) module for implementation details.
64+
65+
### S3, CloudFront, and Cognito
66+
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.
4467

45-
# Deployment Steps
68+
## Deployment Steps
4669
To deploy your dbt docs website, follow these steps:
4770

4871
1. **Configure AWS Credentials:**
@@ -53,27 +76,27 @@ To deploy your dbt docs website, follow these steps:
5376
```
5477

5578
2. **Initialize Terraform:**
56-
Initialize Terraform in the project directory using the following command:
79+
Initialize Terraform in the project directory using the following command:
5780

58-
```
59-
terraform init
60-
```
81+
```
82+
terraform init
83+
```
6184

6285
3. **Format Terraform Configuration:**
63-
Ensure that your Terraform configuration files are properly formatted for consistency:
86+
Ensure that your Terraform configuration files are properly formatted for consistency:
6487

65-
```
66-
terraform fmt -recursive
67-
```
88+
```
89+
terraform fmt -recursive
90+
```
6891

6992
4. **Deploy the Infrastructure:**
70-
Apply the Terraform configuration to deploy your infrastructure:
93+
Apply the Terraform configuration to deploy your infrastructure:
7194

72-
```
73-
terraform apply
74-
```
95+
```
96+
terraform apply
97+
```
7598

76-
# Reference
99+
## Reference
77100
Here are some useful references and resources related to hosting dbt docs and implementing authentication:
78101

79102
- [AWS Static Website Hosting with Cognito and S3](https://howtoember.wordpress.com/2020/06/11/aws-static-website-hosting-with-cognito-and-s3/)
@@ -82,3 +105,4 @@ Here are some useful references and resources related to hosting dbt docs and im
82105
- [Cognito Auth Example (sashee GitHub)](https://github.com/sashee/cognito-auth-example)
83106
- [Terraform AWS Lambda@Edge Cognito Authentication (disney GitHub)](https://github.com/disney/terraform-aws-lambda-at-edge-cognito-authentication)
84107
- [Validate User Email Domain AWS Cognito](https://andreybleme.com/2020-01-18/validate-user-email-domain-aws-cognito/)
108+
- [Microsoft Entra ID Documentation](https://docs.microsoft.com/en-us/azure/active-directory/)

dbt-docs/terraform/cloudfront-microsoft-sso/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
- [Microsoft Entra ID SSO for CloudFront](#microsoft-entra-id-sso-for-cloudfront)
2+
- [Architecture](#architecture)
3+
- [How It Works](#how-it-works)
4+
- [Quick Start](#quick-start)
5+
- [1. Register Microsoft Entra ID Application](#1-register-microsoft-entra-id-application)
6+
- [2. Store Credentials](#2-store-credentials)
7+
- [3. Deploy Module](#3-deploy-module)
8+
- [4. Configure CloudFront](#4-configure-cloudfront)
9+
- [Module Inputs](#module-inputs)
10+
- [Module Outputs](#module-outputs)
11+
- [Troubleshooting](#troubleshooting)
12+
- [Security Features](#security-features)
13+
114
# Microsoft Entra ID SSO for CloudFront
215

316
A Terraform module to implement Microsoft Entra ID (Azure AD) authentication for CloudFront static websites using Lambda@Edge.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Microsoft Entra ID SSO Test Page</title>
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
line-height: 1.6;
11+
max-width: 800px;
12+
margin: 0 auto;
13+
padding: 20px;
14+
color: #333;
15+
}
16+
h1 {
17+
color: #0078D4;
18+
border-bottom: 2px solid #0078D4;
19+
padding-bottom: 10px;
20+
}
21+
.card {
22+
background-color: #f9f9f9;
23+
border-radius: 8px;
24+
padding: 20px;
25+
margin: 20px 0;
26+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
27+
}
28+
.success {
29+
background-color: #e6f7e6;
30+
border-left: 4px solid #28a745;
31+
}
32+
.info {
33+
background-color: #e6f3ff;
34+
border-left: 4px solid #0078D4;
35+
}
36+
code {
37+
background-color: #f1f1f1;
38+
padding: 2px 5px;
39+
border-radius: 3px;
40+
font-family: monospace;
41+
}
42+
</style>
43+
</head>
44+
<body>
45+
<h1>Microsoft Entra ID SSO Test Page</h1>
46+
47+
<div class="card success">
48+
<h2>Authentication Successful!</h2>
49+
<p>If you can see this page, your SSO authentication is working correctly.</p>
50+
</div>
51+
52+
<div class="card info">
53+
<h2>Session Information</h2>
54+
<p>Your session is secured by Microsoft Entra ID (formerly Azure AD).</p>
55+
<p>The authentication is handled via Lambda@Edge functions that validate your session token.</p>
56+
</div>
57+
58+
<div class="card">
59+
<h2>How It Works</h2>
60+
<p>This page is protected by:</p>
61+
<ul>
62+
<li>CloudFront distribution with Lambda@Edge integration</li>
63+
<li>Microsoft Entra ID authentication</li>
64+
<li>Secure, HTTP-only session cookies</li>
65+
</ul>
66+
</div>
67+
68+
<div class="card">
69+
<h2>Testing Notes</h2>
70+
<p>To verify that authentication is working correctly:</p>
71+
<ol>
72+
<li>Try accessing this page in a private/incognito window</li>
73+
<li>You should be redirected to the Microsoft login page</li>
74+
<li>After login, you should be redirected back here</li>
75+
<li>Clear browser cookies to test the flow again</li>
76+
</ol>
77+
</div>
78+
79+
<footer>
80+
<p><small>Powered by CloudFront and Microsoft Entra ID SSO</small></p>
81+
<p><small>Current time: <script>document.write(new Date().toLocaleString());</script></small></p>
82+
</footer>
83+
</body>
84+
</html>

dbt-docs/terraform/modules/cloudfront-microsoft-sso/lambda.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ resource "null_resource" "prepare_authenticator" {
2727
}
2828

2929
provisioner "local-exec" {
30-
interpreter = ["/bin/bash", "-c"]
30+
# Don't specify interpreter, let Terraform use the default shell
31+
# interpreter = ["/bin/bash", "-c"]
3132
command = "rm -rf ${local.temp_authenticator_dir} && mkdir -p ${local.temp_authenticator_dir} && cp -r ${local.sso_authenticator_dir}/* ${local.temp_authenticator_dir}/ && sed -i 's/const SECRET_NAME = \"SECRET-NAME-PLACEHOLDER\";/const SECRET_NAME = \"${local.secret_name}\";/g' ${local.temp_authenticator_dir}/authenticator.js"
3233
}
3334
}
@@ -40,7 +41,8 @@ resource "null_resource" "prepare_callback" {
4041
}
4142

4243
provisioner "local-exec" {
43-
interpreter = ["/bin/bash", "-c"]
44+
# Don't specify interpreter, let Terraform use the default shell
45+
# interpreter = ["/bin/bash", "-c"]
4446
command = "rm -rf ${local.temp_callback_dir} && mkdir -p ${local.temp_callback_dir} && cp -r ${local.sso_callback_dir}/* ${local.temp_callback_dir}/ && sed -i 's/const SECRET_NAME = \"SECRET-NAME-PLACEHOLDER\";/const SECRET_NAME = \"${local.secret_name}\";/g' ${local.temp_callback_dir}/callback-handler.js"
4547
}
4648
}

0 commit comments

Comments
 (0)