tfparse is a Python extension for parsing and evaluating Terraform HCL configuration files.
Terraform's HCL format requires extensive variable interpolation, function evaluation, and expression handling that goes beyond standard HCL parsing. tfparse solves this by wrapping Terraform's canonical implementation and combining it with defsec's interpolation and evaluation engine, providing a high-level Python interface for parsing Terraform modules. This approach ensures compatibility with real-world Terraform usage patterns that involve complex variable references and dynamic expressions.
Developers should use tfparse when they need to programmatically analyze or process Terraform configurations from Python. It suits projects that require parsing complete Terraform modules after `terraform init` has been run to resolve module references. The tool distributes prebuilt binaries for macOS (both x86_64 and arm64), Linux (x86_64 and aarch64), and Windows, though Windows builds currently have a memory management limitation where allocated memory from parse results is not freed.
The project maintains active development with a test suite using pytest and supports building from source with Go 1.18 or later and Python 3.10 or later. Cross-platform compilation is tested through CI/CD pipelines that verify wheel builds across different architectures. The codebase is structured to support both installation into Python environments and distribution as wheels or source artifacts to package repositories.