Transformation: dbt
Last updated
pipelines/
├── transform/ # dbt project root
│ ├── Dockerfile
│ ├── dbt_project.yml # dbt project configuration
│ ├── sources/
│ │ ├──<source_name>.yml # List all landing tables for a source
│ ├── models/
│ │ ├── staging/ # Staging models (first transformation layer)
│ │ └── mart/ # Final business-ready models
│ └── ...
└── ecs_task_dbt.tf # Terraform creating the ECS tasksources:
- name: <source_name>
schema: <landing_schema>
tables:
- name: <source_name>__dlt_version
- name: <source_name>__dlt_loads
...cd pipelines/transform
uvx boringdata dbt import-source --source ../ingest/<source_name>-schema/uv venv --python=python3.12
uv pip install -r requirements.txt
uv run dbt depslocal:
target: <environment>
outputs:
<environment>:
type: athena
database: awsdatacatalog
region_name: "{{ env_var('AWS_REGION') }}"
schema: "<environment>_staging"
s3_staging_dir: "s3://<environment>-<region>-staging-bucket/athena"
s3_data_dir: "s3://<environment>-<region>-staging-bucket/data"
s3_tmp_table_dir: "s3://<environment>-<region>-staging-bucket/tmp"export DBT_PROFILE=local
export AWS_PROFILE=<your_profile>
export AWS_REGION=<your_region>
# Run a specific model
uv run dbt run --select model_name
# Run with Makefile shortcut
make run-local cmd="run --select model_name"export AWS_PROFILE=<your_profile>
export ENVIRONMENT=<your_environment>
make run cmd="run"# Set required environment variables
export AWS_PROFILE=<your_profile>
export ENVIRONMENT=<your_environment>
cd pipelines/transform
# Build and deploy
make deploy# Development
make run-local cmd="run" # Run dbt locally with specified command
make run-local cmd="test" # Run dbt tests locally
make run-local cmd="docs generate" # Generate dbt documentation
# Cloud Execution
make run cmd="run" # Run dbt in ECS Fargate
make run cmd="test" # Run tests in ECS Fargate
# Deployment
make build # Build Docker image
make deploy # Build and deploy to ECR