Skip to main content

Supporting tools for working with terraform code.

Project description

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

# 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

Documentation

For detailed documentation, visit: https://tfmate.readthedocs.org

Development

To set up a development environment:

# Clone the repository
git clone https://github.com/cmalek/terraform-common-modules.git
cd tfmate

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e .

# 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

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tfmate-0.1.4.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tfmate-0.1.4-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

Details for the file tfmate-0.1.4.tar.gz.

File metadata

  • Download URL: tfmate-0.1.4.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for tfmate-0.1.4.tar.gz
Algorithm Hash digest
SHA256 163c6d78bbba82d4ce377a2ee83cba0d474c19e230ae9cb627b1ff90e6e207ed
MD5 2c3189f2bdbda38593a2ef03da6449b7
BLAKE2b-256 aabdc50799dac6ca5b8d2dad528b86f0924405b2a48ffc7a6f47b7e5ed20d923

See more details on using hashes here.

File details

Details for the file tfmate-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: tfmate-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 45.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for tfmate-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 48cf94ae0c95772e20e0c68ab139685000d8f5f1046eca099e3891a4783ce1f2
MD5 6d00c6e9a4aba017ac7b5ea5dad05c62
BLAKE2b-256 a2c838e380ef4f1505eba384fa74747540c896a381f2b699d8cff8f2fb65e647

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page