Skip to main content

bdtemplater

A utility for generating configurations in a brain-dead style using input from properties files.

By default, a terraform.tfvars file is used as input, which contains key-value pairs for a Terraform configuration.

By default, the tool reads a file called DEFAULT.bdt

Values are substituted by a key arrangement, where the key is defined as @key@ in the template file (i.e surrounded by @ symbols).

Features

  • Parse properties files, like Terraform .tfvars files
  • Generate configured output from templates
  • Support for custom post-processing functions
  • Command line interface for easy usage

Installation

Using uv (recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

uv tool install bdtemplater # This is usually what you want to do

# or install the package
uv pip install bdtemplater

# Or install in development mode with all dependencies
uv sync --group dev

Traditional pip

pip install bdtemplater

Usage

Command Line

Basic Usage

bdtemplater --help # Show help

bdtemplater # Write output to stdout using terraform.tfvars values and DEFAULT.bdt template

bdtemplater NEWTEMPLATEFILE.bdt # Write output to stdout using terraform.tfvars values
bdtemplater DEFAULT.bdt mytfvars.tfvars # Write output to stdout using mytfvars.tfvars values

bdtemplater --output myoutputfile.tf # Write DEFAULT.bdt + terraform.tfvars output to myoutputfile.tf 

bdtemplater -k a,b,c # Use only keys a, b, c from terraform.tfvars

# Use a post-processing script. 
bdtemplater --import-module mymodule --post-process mypostprocess.py --output 

Using installed command

# Generate terraform configuration from terraform.tfvars
bdtemplater

# Or run directly with uv
uv run bdtemplater

Python API

from bdtemplater.bdtemplatize import generate_template

# Generate configuration
terraform_template = """
provider "aws" {
  region = var.region
}
"""

terraform_tfvars = """
project = "my-project"
env = "production"
bucket = "my-terraform-bucket"
region = "us-west-2"
lock_table = "my-lock-table"
databricks_version = "1.25.0"  # optional, defaults to 1.25.0
"""
result = generate_template(terraform_template, terraform_tfvars)
print(result)

Development

This project uses uv for dependency management and building.

Setup Development Environment

It is highly recommended that you use the devcontainer defined in .devcontainer for a consistent development environment.

Otherwise, you will need uv and make installed.

# Install development dependencies
uv sync --group dev

Running Tests

# Run simple tests (no dependencies required)
uv run python -m tests.simple_test_bdtemplatize

# Run full test suite
uv run --group test pytest tests/ -v

# Run tests with coverage
uv run --group test pytest tests/ --cov=src --cov-report=term-missing

# Or use make commands
make test
make test-cov

Code Quality

# Format code
uv run --group lint black src tests
uv run --group lint ruff format src tests

# Lint code
uv run --group lint ruff check src tests

# Type check
uv run --group lint mypy src

# use make commands
make format
make lint
make type-check

Building and Publishing

# Build the package
uv build

# Install locally
uv pip install .

Makefile Commands

For convenience, use the included Makefile:

make help            # Show all available commands
make dev-install     # Install with development dependencies  
make test            # Run all tests
make test-simple     # Run simple tests only
make test-script     # Test the direct bdtemplater script
make install-script  # Install bdtemplater script globally
make uninstall-script # Remove installed script
make lint            # Run code linting
make format          # Format code
make type-check      # Run type checking
make build           # Build the package
make clean           # Clean build artifacts

Configuration

The tool expects a terraform.tfvars file with the following variables:

project = "my-project"
env = "production"
bucket = "my-terraform-bucket"
region = "us-west-2"
lock_table = "my-lock-table"
databricks_version = "1.25.0"  # optional, defaults to 1.25.0

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

See the LICENSE file for full license text.

Metadata

Release files for bdtemplater 0.11.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bdtemplater 0.11.2
File Size Uploaded
bdtemplater-0.11.2.tar.gz 36.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bdtemplater 0.11.2
File Interpreter ABI Platform
bdtemplater-0.11.2-py3-none-any.whl Python 3 none any Details

Total release size: 54.2 kB

Release files / bdtemplater-0.11.2.tar.gz

Download URL bdtemplater-0.11.2.tar.gz
Size 36.9 kB
Tags Source
SHA-256 checksum
How to use checksums
005b6eb1e0b9093027cdf1da15c8c2c9dfa0cd8917d9b4c29760db74cd6597b1
BLAKE2b-256 checksum
How to use checksums
be354911a77076dc86feb1b5d1069b569fabac9647b500edfb22fcd8d2761d1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / bdtemplater-0.11.2-py3-none-any.whl

Download URL bdtemplater-0.11.2-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33809af85304fabd2b95a2517bb54fb8d09c35e97d28b6ce430b4463273e95ab
BLAKE2b-256 checksum
How to use checksums
d0b3cb5d41fbdbd451b13fb7e7188a20ca5cda31b0bd3700311680cc24844268
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.11.2 This release

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page