tfparse
Python HCL/Terraform parser via extension for AquaSecurity defsec
What it is and what it does
tfparse is a Python extension that wraps Go bindings to Terraform's canonical HCL parser and the defsec evaluation engine. It handles the full complexity of Terraform configuration parsing, including variable interpolation, function evaluation, and expression resolution—going beyond what a standard HCL parser can do. The library exposes a high-level Python interface to load and inspect parsed Terraform modules as dictionaries.
The package is built on cffi bindings to Go code and ships precompiled wheels for common platforms. It is intended for developers who need to programmatically analyze or process Terraform configurations in Python, such as linting tools, policy engines, or infrastructure scanning utilities.
Use it for:
- Analyze Terraform modules programmatically to extract resource definitions and validate configurations.
- Build policy-as-code or compliance scanning tools that need to understand Terraform state and expressions.
- Integrate Terraform parsing into Python-based infrastructure-as-code tooling or CI/CD pipelines.
- Extract metadata from Terraform modules for documentation generation or dependency mapping.
- Validate Terraform configurations before deployment by inspecting parsed structure and values.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
tfparse parses and evaluates Terraform HCL configuration files using Go bindings to the canonical Terraform implementation and defsec evaluation engine.
Yes, if you need to parse and evaluate Terraform configurations in Python. The package is actively maintained, has no known vulnerabilities, and uses a permissive license. Install friction is moderate due to compiled extensions, but prebuilt wheels cover common platforms. Note the Windows memory management caveat if that is a deployment target.
Install
tfparse on PyPI
pip
pip install tfparseuv
uv add tfparsepoetry
poetry add tfparseInstalling tfparse
Before you install
Medium install friction due to compiled C extensions (cffi-based bindings to Go). Prebuilt wheels available for Python 3.10–3.14 on macOS (x86_64, arm64), Linux (x86_64, aarch64), and Windows. Active maintenance with a recent release.
License in practice
Apache-2.0 permissive license allows use in most commercial and open-source projects without significant restrictions.
Quickstart
pip install tfparse
from tfparse import load_from_path
parsed = load_from_path('path_to_terraform_root')
print(parsed.keys())
Requires terraform init to have been run on the target directory to resolve module references.
Verify before relying
- Memory management on Windows (documentation notes memory is not freed on parse results; impact on long-running or high-volume parsing unclear).
- Exact scope of Terraform version compatibility and which HCL2 features are fully supported.
- Performance characteristics and scalability limits for large module hierarchies.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — cffi |
| Maintenance | actively maintained — 78 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 156,620/month — #10,780 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tfparse-0.6.20-cp310-cp310-macosx_10_9_x86_64.whl; tfparse-0.6.20-cp310-cp310-macosx_11_0_arm64.whl; tfparse-0.6.20-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tfparse-0.6.20-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tfparse-0.6.20-cp310-cp310-win_amd64.whl; tfparse-0.6.20-cp311-cp311-macosx_10_9_x86_64.whl; tfparse-0.6.20-cp311-cp311-macosx_11_0_arm64.whl; tfparse-0.6.20-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tfparse-0.6.20-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tfparse-0.6.20-cp311-cp311-win_amd64.whl; tfparse-0.6.20-cp312-cp312-macosx_10_13_x86_64.whl; tfparse-0.6.20-cp312-cp312-macosx_11_0_arm64.whl; tfparse-0.6.20-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tfparse-0.6.20-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tfparse-0.6.20-cp312-cp312-win_amd64.whl; tfparse-0.6.20-cp313-cp313-macosx_10_13_x86_64.whl; tfparse-0.6.20-cp313-cp313-macosx_11_0_arm64.whl; tfparse-0.6.20-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tfparse-0.6.20-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tfparse-0.6.20-cp313-cp313-win_amd64.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
pyhclParses HCL (HashiCorp Configuration Language)…
copyleft · top 5,000 on PyPI
bc-python-hcl2Parses HCL2 configuration files (such as…
permissive · top 5,000 on PyPI
tree-sitter-hclProvides a tree-sitter parser grammar for HCL…
permissive · top 15,000 on PyPI
python-hcl2Parses HCL2 configuration files (used by…
permissive · top 5,000 on PyPI
tftestWraps the Terraform executable to facilitate…
permissive · top 15,000 on PyPI
cdktfDefines cloud infrastructure using Python code…
copyleft · top 15,000 on PyPI
python-terraformWraps the Terraform command-line tool, allowing…
permissive · top 15,000 on PyPI
terraform-complianceterraform-compliance is a BDD-based test…
permissive · top 15,000 on PyPI
terraform-localA wrapper script that runs Terraform against…
permissive · top 15,000 on PyPI
cdktf-cdktf-provider-awsProvides prebuilt Python bindings for the…
copyleft · top 15,000 on PyPI