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 compatibility 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.12-cp312-cp312-win_amd64.whl (8.8 MB view details)

Uploaded CPython 3.12 Windows x86-64

tfparse-0.6.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

tfparse-0.6.12-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.1 MB view details)

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

tfparse-0.6.12-cp312-cp312-macosx_11_0_arm64.whl (8.1 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

tfparse-0.6.12-cp312-cp312-macosx_10_9_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

tfparse-0.6.12-cp311-cp311-win_amd64.whl (8.8 MB view details)

Uploaded CPython 3.11 Windows x86-64

tfparse-0.6.12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

tfparse-0.6.12-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.1 MB view details)

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

tfparse-0.6.12-cp311-cp311-macosx_11_0_arm64.whl (8.1 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

tfparse-0.6.12-cp311-cp311-macosx_10_9_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

tfparse-0.6.12-cp310-cp310-win_amd64.whl (8.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

tfparse-0.6.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

tfparse-0.6.12-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.1 MB view details)

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

tfparse-0.6.12-cp310-cp310-macosx_11_0_arm64.whl (8.1 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

tfparse-0.6.12-cp310-cp310-macosx_10_9_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: tfparse-0.6.12-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 8.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for tfparse-0.6.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 69fa63f55b4099f8df137d931099b3c0af50e4996475e37675e4e79f52b5898e
MD5 703fc378b27156aa19bf5125768d0c74
BLAKE2b-256 fd741e0d8641911ecd11a7804d988a34264c5a5f1ea4e416d0727ce47c63399b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fea2de362ee5e8185ff2e1056f22056d6490ce18192c3e0d89239083d2784589
MD5 07ed1934925726775f841de2cbd1d3a7
BLAKE2b-256 ceca1424c920679dd378664ec7035da09863aec9917a88408535fe7dbb321ced

See more details on using hashes here.

File details

Details for the file tfparse-0.6.12-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.12-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e96bbb09e21e24f38641d124bbe1e69b76155faf69c79957024a2423cd60435
MD5 3059cdaa3bbd599b58f24f210e97d221
BLAKE2b-256 4121c9c7ede949c8a61cea1291e0c9e27c02334d793f15025061344775cbbab1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 550a86fd88cbc4492ec9c7e3bc1b252a0cf08b82d933502fc1f78939296925b3
MD5 32cdb256a6f448911bc1a162e6471acc
BLAKE2b-256 7d8d1725976a3fdde61763b6bd7bdcffb8642f500ade50ba906500ab2756c1fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 929e4d9b173ef0bda09443a0cda49646a5ec8bb5ed91e10013702421cf473566
MD5 469311835eff1d765e36e498d6048707
BLAKE2b-256 ad61fbb252a9581e48ff8bb88b6655e4750cf939011a10b58a2bcfa3c8a0b7b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tfparse-0.6.12-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 8.8 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for tfparse-0.6.12-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 98712633a18fcfc2544e7bcde5833e79bbe879088a4d72ca604b23bc6e9b7121
MD5 5d7280d6d15cfd2beb154015eb324c5b
BLAKE2b-256 7c6883ba440eb8e7cee12b192e39b353dc18061906c40fd774b536d3e029c6a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d542ee1632bd914fe1477005aec324af859c7b150b0f0deaf0b6210549633712
MD5 b3a6d029174e0da0f31fcb6eda926db5
BLAKE2b-256 caf3f8c1dad46768189316df14318560a7f40e5d22baf58c041a58969adfcdb0

See more details on using hashes here.

File details

Details for the file tfparse-0.6.12-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.12-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b3f0783be97c8658fd04872ae35b3118766699d20cb57baaabbff06855a8338
MD5 aa7ac85abf8427a71fa83fba5e0f175d
BLAKE2b-256 9ff6ad555964e02e6a7f246f543d380f513a599840143eb5e551691e80a6adfa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eac233d361355f41211afb3f2a7d254f1e815949395f51816b8d48dbb22e7266
MD5 03642d6f25e47e85e592a66151c8a21b
BLAKE2b-256 509e8643fb7aaede44765cdf2f2fff2d3f946dc4453a60db56b6f23f7f4eb64d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1788070642d4ad8535e410270bec39eba1ac5341ea16bdcf2cacfc052353bcd4
MD5 4a2be6384f1d55c6169740b151c632cb
BLAKE2b-256 0bb88b292d7840b3c778fec3d662f65876d607cdf9e1c0b616b85f99b4df3809

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tfparse-0.6.12-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 8.8 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.7

File hashes

Hashes for tfparse-0.6.12-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 799a36df7ef4a2ac4683ea2c400f3f8b81d8c5c40dca449a860db362a752b329
MD5 50ed808bc1db35a24bc167c2d002ab7d
BLAKE2b-256 e9e291919c4a7d8b0b0b2d0707968577ededfc7cfb7bb5c782323b8e57df8127

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f3b232c8b09383d90368de26175794a10502b1ced046f830a2a6822cf756a003
MD5 e95b4fd9e8f433d35f1aa4d564659306
BLAKE2b-256 161e69bf5fbb0736802594c6bde09ced3efb9a6cbdf6fd9d3708668478cc01c3

See more details on using hashes here.

File details

Details for the file tfparse-0.6.12-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.12-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 925b2bab3abf5ee8edb6019805387e3c3da683c263adc0b271e1f02a3eac88fb
MD5 23e3f3096b9b7588a9370db5bbd9f37a
BLAKE2b-256 5181cddd23d5b35acc91f623c27b46f2a57d0582b9b39b994b3a2c50f0e29670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de8c5f2d92fd1600d85acde8d2b90e624edab3bf03edf1bb8a8d75bbd43e10e1
MD5 7e6c48146c3f06a6a0e9a6f4be352f36
BLAKE2b-256 5f47d57ab3a21bf7036f8314c796288569a807a7590b7070daaf8446bfdd557f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.12-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2568adac95698d2c3a00ff0df5bb0b134bb0237a1a8855231b73f460c45771c0
MD5 85be6138f6e1723dd4b900a941c6a4e0
BLAKE2b-256 a495288806d167c646a7322c8d3793dd3e92762710ec65f28803da10eb19e516

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