skillfed

tfparse

Python HCL/Terraform parser via extension for AquaSecurity defsec

tfparse v0.6.20 156.6K downloads/30d#10,780 on PyPI57
Permissive license Apache-2.0 Active released

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 tfparse

uv

uv add tfparse

poetry

poetry add tfparse

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

terraform hcl parserparse terraform modulesterraform configuration parsinghcl evaluationterraform ast extractioninfrastructure as code parsingterraform file analysis
terraforminfrastructure-as-codehcl-parser

More Build Tools packages