tfmate
Documentation: https://tfmate.readthedocs.org
tfmate is a command line interface and Python library for analyzing Terraform configurations and state files. It provides powerful tools for understanding your infrastructure as code, including configuration analysis, AWS service discovery, and state file inspection.
Features
- Configuration Analysis: Analyze Terraform configuration files to understand providers, backends, and version constraints
- AWS Service Discovery: List and filter AWS services from botocore definitions
- State File Inspection: Extract Terraform version and metadata from state files
- Multiple Output Formats: Support for JSON, table, and text output formats
- Flexible Configuration: Customizable through configuration files and environment variables
Installation
tfmate supports Python 3.10+.
To install from PyPI:
pip install tfmate
To install using uv:
sh -c "$(curl -fsSL https://astral.sh/uv/install)"
uv tool install tfmate
Ensure you have ./local/bin in your PATH, since that's where uv puts the
executable.
Quick Start
# Get help
tfmate --help
# Analyze Terraform configuration
tfmate analyze config
# List AWS services
tfmate aws services
# Get Terraform version from state
tfmate terraform version
# Recurse through all your .terraform folders and delete any unused provider or module code.
tfmate terraform prune-cache
# Use JSON output for scripting
tfmate --output json analyze config
Usage Examples
Analyze Terraform Configuration
# Analyze current directory
tfmate analyze config
# Analyze specific directory with detailed info
tfmate analyze config --directory ./infrastructure --show-providers --show-backend
# Output as JSON for scripting
tfmate --output json analyze config > config.json
AWS Service Discovery
# List all AWS services
tfmate aws services
# List only service names
tfmate aws services --names-only
# Filter services by pattern
tfmate aws services --filter-name "ec2*" --sort-by name
State File Operations
# Get Terraform version from state
tfmate terraform version
# Get version from specific directory
tfmate terraform version --directory ./infrastructure
# Use explicit state file (local only)
tfmate terraform version --state-file ./terraform.tfstate
Prune Stale Provider/Module Cache
# Recursively find .terraform cache directories and interactively prune stale
# provider versions and orphaned module checkouts left behind by
# `terraform init --upgrade`, comparing against .terraform.lock.hcl and
# modules.json
tfmate terraform prune-cache
# Preview what would be pruned without prompting or deleting anything
tfmate terraform prune-cache --dry-run
# Prune a specific directory tree
tfmate terraform prune-cache ./infrastructure
Documentation
For detailed documentation, visit: https://tfmate.readthedocs.org
Development
To set up a development environment:
# Clone the repository
git clone https://github.com/caltechads/tfmate.git
cd tfmate
uv sync
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Run tests
pytest
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
See LICENSE.txt in this project for the license.
Metadata
Release files for tfmate 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tfmate-0.3.1.tar.gz | 54.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tfmate-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 232.0 kB
Release files / tfmate-0.3.1.tar.gz
| Download URL | tfmate-0.3.1.tar.gz |
|---|---|
| Size | 54.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed3d2dca1e76cc04acd1f44b48af0c4df393b35143bf7f70b07c2b756ddd0d79
|
|
BLAKE2b-256 checksum How to use checksums |
3a18eab7bbcc67e83637047fa577225e9f6140e545aa20b3c68b589bfb83fd0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.10
|
Release files / tfmate-0.3.1-py3-none-any.whl
| Download URL | tfmate-0.3.1-py3-none-any.whl |
|---|---|
| Size | 177.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ad7a57f9d5ec001501d34cd64356bcea2162ab6d5539b940edf72846a717377
|
|
BLAKE2b-256 checksum How to use checksums |
191efb1a4bcc4e3c4fe3e2ef4678a0eafcda7539e6ce3bd3eb49275273d0cced
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.10
|
Security for tfmate 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.