Skip to main content

Python HCL/Terraform parser via extension for AquaSecurity defsec

Project description

What

A python extension for parsing and evaluating terraform using defsec.

While terraform uses HCL as its configuration format, it requires numerous forms of variable interpolation, function and expression evaluation, which is beyond the typical usage of an hcl parser. To achieve compatiblity with the myriad real world usages of terraform, this library uses the canonical implementation from terraform, along with the interpolation and evaluation from defsec to offer a high level interface to parsing terraform modules.

Installation

pip install tfparse

We currently distribute binaries for MacOS (x86_64, arm64) and Linux (x86_64, aarch64) and Windows.

Note on Windows we currently don't free memory allocated on parse results.

Usage

A terraform module root, with terraform init having been performed to resolve module references.

from tfparse import load_from_path
parsed = load_from_path('path_to_terraform_root')
print(parsed.keys())

Developing

  • requires Go >= 1.18
  • requires Python >= 3.10

Installing from source

Installing will build the module and install the local copy of tfparse in to the current Python environment.

> pip install -e .
> python
>>> from tfparse import load_from_path
>>> parsed = load_from_path('<path_to_terraform>')
>>> print(parsed.keys())

Building from source

Building will produce a wheel and a source artifact for distribution or upload to package repositories.

python setup.py bdist_wheel
ls -l dist/

Running the tests

This project uses pytest

pytest

Testing CI Builds for cross compiling

You can test our cross compiling CI/CD builds by running the following:

CIBW_BUILD=cp310* cibuildwheel --platform macos --archs x86_64

This will try to build an intel wheel on python3.10

Credits

aquasecurity/defsec - golang module for parsing and evaluating terraform hcl

Scalr/pygohcl - python bindings for terraform hcl via golang extension

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

tfparse-0.6.9-cp312-cp312-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

tfparse-0.6.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

tfparse-0.6.9-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

tfparse-0.6.9-cp312-cp312-macosx_11_0_arm64.whl (8.0 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

tfparse-0.6.9-cp312-cp312-macosx_10_9_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

tfparse-0.6.9-cp311-cp311-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

tfparse-0.6.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

tfparse-0.6.9-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

tfparse-0.6.9-cp311-cp311-macosx_11_0_arm64.whl (8.0 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

tfparse-0.6.9-cp311-cp311-macosx_10_9_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

tfparse-0.6.9-cp310-cp310-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

tfparse-0.6.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

tfparse-0.6.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

tfparse-0.6.9-cp310-cp310-macosx_11_0_arm64.whl (8.0 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

tfparse-0.6.9-cp310-cp310-macosx_10_9_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

File details

Details for the file tfparse-0.6.9-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 30b4c79359405171be50e484f163725bdd7599acb0c6bf1763056fe0947deb44
MD5 8ea84445685327774375ffb8a7f3c2c4
BLAKE2b-256 5effea131d6d4a79a9ecb9f1c3af1960f9e65900814936c68f7c4e24778e8104

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7d571f1d49b57455d27657d76b44c03422d9c48127864cf7785e5bf16e3700e9
MD5 9ee3b361d055c7ddbd0fbe2fdbeddcb9
BLAKE2b-256 19ff93eef2e07e89109527212c0c57c8d2bae1efaed8d647a982c69c7a198137

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tfparse-0.6.9-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e5eade4c8218b9d112d4f42338b9a4ffbe280ea2041bc3affbc275b9380311c8
MD5 b431f5081105d3709d5a621401009b6f
BLAKE2b-256 051b7dab0c972025838d385104ba78149e26e06e3be5014232f50ae8c52ee456

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76261806eb2b9a2d34126cbbf10913aa171520698ca9edc6f5c0b85f17bf4ad0
MD5 2bc516665c8e96b31a322a45193d87ff
BLAKE2b-256 6de51b0a295aa40b2e7e49f8ec67ef80fa81096e966582bdd2b2f9d07ad1743a

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp312-cp312-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.12, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 471868bf3117fb32045909a93f4e618400912b2d9daf998e5037fb0aa7a4d1ff
MD5 6e7b65f97cd7f6505c629b6e9e76594f
BLAKE2b-256 db367631029125d5eb7da6065e651e08948e8d929012d45db9afc287904d0a4f

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 01840577f660c9d955e98d114b2b7a0501513310614471e6597a2394a8f022d0
MD5 c2052032470656d560b5eb00e5f6c0f5
BLAKE2b-256 d99806050e47a9826c13deb6109ed25bfe8a4c670449d6e6d951a79276b55f8c

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c85922f0c20771a7619d2d58498b432ba5ab12c682829e2d1011e29040f0c7dc
MD5 17f4a416626cdb25f4f1de525e75cf8e
BLAKE2b-256 5ab2aab9aaff33cafb4766823e26223c221438477ddd046c573b0e180874e7b2

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tfparse-0.6.9-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d07989394ebd6b7dd532b7424f45eb33d0622007405bccc04e50612a4096d175
MD5 3e7b6b09a8d626cfe558142a507a41e4
BLAKE2b-256 698bec7e07f26c7a0503c02f4275f5a64ef243f952ee9fc28bd4074098575606

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: CPython 3.11, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab7d5da78ed9db3b7729954d2e550cee7191c2710a3a8ec51c1941ee0dd361ab
MD5 270f349dbee039434740e4438315ae7a
BLAKE2b-256 9bc7f9838a3ad2d746161f1d227df0713e1dfdd644692e86047f2e201dadb58a

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp311-cp311-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.11, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fda8de849638eae7fb4cc86685522a03a9721415a6f0c009588794b384eb57b8
MD5 0d350450dc787946da4b75bff45669c8
BLAKE2b-256 25e9356a1eff818c7da7360b654df7b2c519b43f094f3d844e778d0005d3deb3

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6b2e7036fd3a12746d2b7674cfb232c5d9f2b8d387f3c12abc3c78077777c0ea
MD5 7ca26860f79421c5f6c3a859ad4f870a
BLAKE2b-256 a3d86f6887f5f88436cf780fe5e500bba91347c2f1fc9f52a8907c993f4986a1

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 45cd8b68ad7d82178e3e4964eedc2b71b6bab327c7e0c7ac4d13f42e79d4f9ab
MD5 d7ba2617e968a43cbdedf682efc91876
BLAKE2b-256 62bcd6f6ee41e12fbb404e8fbfc6e2c94e0e7b90c22085bebc80709d08db0815

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tfparse-0.6.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84a2c2e74dffaeac43ef56ee08b59e50dc12bfc8aed125ae77360257d8161ee6
MD5 3b10e0ede37538be1d813e8af631e4d0
BLAKE2b-256 a6c4a4638d8386fdf522d4c21b6f83b85b1ae7606f5ff86cfba2e80ea2ad0eaa

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: CPython 3.10, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b514df7fe5e1f15f1721b3e117eac09234d953adffa43967d5a908135fa88bc
MD5 e54c720844c869b1bc383ddc96683863
BLAKE2b-256 527bb86eddd85580c030711817534f857471d90b6a8d7679394e983cbcf4a102

See more details on using hashes here.

File details

Details for the file tfparse-0.6.9-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: tfparse-0.6.9-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.11.0 readme-renderer/43.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.66.4 importlib-metadata/6.11.0 keyring/25.2.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.3

File hashes

Hashes for tfparse-0.6.9-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bd131e17ff0e21e637f1a5eaccc1bcc60f3fabdbaee4c8e0151632bd94fe0292
MD5 13f9b397af863f0651a888d2b732fc78
BLAKE2b-256 7eaee309314f53b08ba89706a569f547fe43587c65a2bb985279ea1103986e5a

See more details on using hashes here.

Supported by

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