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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

tfparse-0.6.8-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.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

tfparse-0.6.8-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.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

tfparse-0.6.8-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.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for tfparse-0.6.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 040e5f29d52cb6bf86f04e7f1503cd8edda1dfdd415d5c0731e92fddc54bcd0a
MD5 2307280cf3421484578abff5a1b1bd1b
BLAKE2b-256 9ef9fa73f042953c0780bbcb98301f53bdea84875d060ca6c9b430a8bf2c041d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4bfb1aed1a3e69d788744ee33b757ecedbbb520a4f3de6b5bee706dff13c534
MD5 55e5d41625f0c5a0b173cee38ac25e3a
BLAKE2b-256 c1eaf80662c23a6dbd91937b19919d9cf1be50b5a840e3bde4938cd1800c6527

See more details on using hashes here.

File details

Details for the file tfparse-0.6.8-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.8-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c4ad78276530bbe4bc9d5b8e98f9a276e302e5a78c63b1db54f38b390a009ee
MD5 d97203f816330dc2b539e883042e197d
BLAKE2b-256 236d9c68a835d0cc351e37482a7f01e7fd229394303ca2b7cb97a306e6496df3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b3d50c79a37cb7c5e0982214313fa540dc4584b3bea37402de2b477b8d6de38
MD5 106ef4a3c1fb09e330b6cb926f89db04
BLAKE2b-256 37081c76e55f82790f7dc3479cf4828bc9dd23c3a2efe30197115545d0f4da5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a4b1678dd704b872ed0b54ed2580b17610c35c3b6181bf24e4a4aebe9e1fc9e8
MD5 094d13cc857faeb91c08bcc6d1e36d56
BLAKE2b-256 341a5c0fefa4a437d6a3fff72894915df7900146c3208d433d73752a0e50b845

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tfparse-0.6.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 885114c36be9e05a5522bafe9634092e3808213294d39ba5ba87ffc8ca961f1b
MD5 716708a6eb9456c837862848f15bb0a5
BLAKE2b-256 aecf2a47901a4655c353c107ba27194aee816ce30f4e8bc4b167f06bcff922ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6dbd583b5dc704c68ee65ffa9a2c5fa09217a8dd039bd18c118d37de35be622d
MD5 80ec2d15438b8469239fe4a1687950b1
BLAKE2b-256 12d841fd4d85aeb19302cd2ba9b166993aac10c3f953cc3b52602c528e35874f

See more details on using hashes here.

File details

Details for the file tfparse-0.6.8-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.8-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2908555addf21e751dbeece6dacacb5d2da59ab71c711145c32e0746f0bd207e
MD5 acb6a065a50c8f077bcb852b944f1912
BLAKE2b-256 4ace3e64a6bd8f5731a860222d3760459c8e6961c667eca65960eac027bcbfe8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9197b169a908a765884075a2038775657beb1de3f326477f58e838e619292b02
MD5 97688d3fabf396b15d0d1699e781827f
BLAKE2b-256 b0dbda9501598470e9632c3e6ae770ceb0b7f4c1133066cd3d34c6a709c0bc8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3aabca2416a03c125f0bdbb5fc1465b70753bf49d2eeee1b3530d13d12602852
MD5 1af02d66e23e38e8c0f10ff227a813f4
BLAKE2b-256 02b51f4a7cede03ae4128ff3fc5a31837f824227091b77f3462c41eaeabedbe7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tfparse-0.6.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2733b1da48d1674009b03f122b705a2cad390ba492381a85a9fb29ccd98435e7
MD5 1b4a8587c1d867f187c560c1b1a2dc6e
BLAKE2b-256 f4cfeca10fe95562bb4d50abef181560ffc434d2cfbbc4cc6ec576231ee768a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4807a113cd91f53d8087b48ea44ab2e1db63f0d134553666da64fa65c20256b0
MD5 f294ea0218d4c36d0001792785b5b759
BLAKE2b-256 9989c41fda8ecfb60544d034145cbe541656feeae2e1aafcda0d7fcf77fd0629

See more details on using hashes here.

File details

Details for the file tfparse-0.6.8-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.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54668571c60010a1679669b1ec24d04e12320a0cfb202be27ecead322746393c
MD5 c6cf3efee9e2617433bc6830b77d4c7d
BLAKE2b-256 88cf3235cd58b290039f9d5cf195d4f5fe8768249d3e9711283130670c4530c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd1dfddc60619adbd0e2fa4b51a7449d1b6505ad0ec7618999388441d28e0c23
MD5 d2598c9215895fa755531f97789ee7cc
BLAKE2b-256 08634a1cbd7796f6ee8c06741e6aa6b90d583aefc07d1b39c372c95417cbc84f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.8-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 57cb96950b5520489a186fa3b73a12b84f3a53cdd4f370df58be591629815d63
MD5 59e55dcf623a96cc0a491ca13bcf6821
BLAKE2b-256 5dc86756f944ab0d98bd6ae18ed5be1e6d68c932326fea031b8c121922d96303

See more details on using hashes here.

Supported by

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