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

Uploaded CPython 3.12 Windows x86-64

tfparse-0.6.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

tfparse-0.6.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.7 MB view details)

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

tfparse-0.6.7-cp312-cp312-macosx_11_0_arm64.whl (8.2 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

tfparse-0.6.7-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.7-cp311-cp311-win_amd64.whl (8.4 MB view details)

Uploaded CPython 3.11 Windows x86-64

tfparse-0.6.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

tfparse-0.6.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.7 MB view details)

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

tfparse-0.6.7-cp311-cp311-macosx_11_0_arm64.whl (8.2 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

tfparse-0.6.7-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.7-cp310-cp310-win_amd64.whl (8.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

tfparse-0.6.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

tfparse-0.6.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.7 MB view details)

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

tfparse-0.6.7-cp310-cp310-macosx_11_0_arm64.whl (8.2 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

tfparse-0.6.7-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.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tfparse-0.6.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for tfparse-0.6.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 36b1e9042231488d94716f0be1d7c9a45051aa9ba9a0fb93fc34a378e53e615a
MD5 c620f9641902af2fd9df7be8a1cede52
BLAKE2b-256 63ebc11eb6e792f72d7d3db433413f84f82370ca3c265c09cc7e868e04546c18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0bccf06c69d493807634d72c524382fb828eda15a25ce6092df10db228f0d330
MD5 20829058f1d04a6fbafb68fea6b55c9f
BLAKE2b-256 c50b6f875113edf7a80d19218adc214b54b082573e0af28c2ba3c4cc6ee80cc4

See more details on using hashes here.

File details

Details for the file tfparse-0.6.7-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.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86b1f5136b8c03d91dfbcc7a7815066eb22c96d936195f1f555071c96d2527ce
MD5 77869e532eebfc1df43542f7f31e3fd1
BLAKE2b-256 62fec292fd08b7b804b5e48ff45c1046474d2996b0b6820cc311e8afe2b1ce04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 82091f1e119ae02ca8fd52de9b02c2965f7921536294f8839d5134266fb7d388
MD5 4e17ee07a8b8257c6dadd8c2a22080cc
BLAKE2b-256 7a3b7d6a41266fff9043eb6aa30ef558d1a78a951c04607c6ec376e42a7e1947

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6678b1d647e39150c2027af6a54ed347ced5ea97f8aa840e0a4483184cb4fe48
MD5 2277db69d5b69544fce2ca60829ac528
BLAKE2b-256 737ddb2262ad83b79bd2d67055f31c1c6e8946f6792467f770c0522a96b10c39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tfparse-0.6.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for tfparse-0.6.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2d1a2fc4abc5d54d704d9d230de939272fd2e532f1a18f41eb0745bfebf5ecdf
MD5 bb72aeba52699eca4ee09c1edc4ef3d3
BLAKE2b-256 b798a98e197f64f5ff6612eec435b7709b0a527d3c94d4516e196ae7ef3ac95b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cbfb28339005716abd765aade1c9928634a31bf510491db6e6162f696c9649e2
MD5 bb14cf2d5dbf5a90ff8242cae50d0f72
BLAKE2b-256 1133ee41a65e6a7e48769a71c2a251863d88c827e330fb9124afaafec3278f77

See more details on using hashes here.

File details

Details for the file tfparse-0.6.7-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.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 743c76ca71cfc37ec3a886066c46d7e5a451b23996559520d5316fcdf2a1fc3e
MD5 95d04f59bac8bec3986c8ead67b5c426
BLAKE2b-256 6094d647448113ec5c113264962ce07d125d8be2d5a7b14a491bfe3fc4b8c814

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a8a54cb45036bbcc4098af1a70acf04acf51c236da2c6c4ca07e61b49c61ffb
MD5 d4b4f40f6cf293a0f8eea88e21923fe1
BLAKE2b-256 32f92d9b2d870bcdd42aa78158cd2213e6417057d0879ce0ee7d7c5833ae35e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d13e43d4a40b61f7aca64ba924319e1c4ba4b57718efa161e89b18c6104a6fa5
MD5 8ea3902e9f59259bb88a6b4b2102eaf5
BLAKE2b-256 53b7ea3a86b7e145d159767dc7b45f43f25dfe2896548115a8370765b6946570

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tfparse-0.6.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 8.4 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for tfparse-0.6.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1a910bc292928f18898f4f7e1d0f31b850b385fb812b55b85867714590d81fbd
MD5 98a4b6887bfb0963093513544ab1455e
BLAKE2b-256 8379eb8412baec88cf7c90f2c9b0cfaad2570ce0aa8cbb186964b9a7979798f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5d9a2010f1261c3d006676635676c3f6f2bcafcb30a49d43f4627f7109a0f595
MD5 f36a7fa1e0ad57e220a7b4322c69b32f
BLAKE2b-256 9659e69d0403fe3734eca760832bc17fdbf1056602f1829efa29f8e33914c071

See more details on using hashes here.

File details

Details for the file tfparse-0.6.7-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.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5561dc793190232f6f1678c9363e58351fff3f5fbd83a58cc87770123d15141f
MD5 c7f60c0e9d120f2d81c45db3a8465e76
BLAKE2b-256 f7af5ba30d88713643ecbdec714d574d9f8b2934c83c26c8202c8f5b1037bce0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86710ceae53c3f47acdabdeb62c98d0181cd1c4b3690a431b4b193cf86ddd42a
MD5 22926a35be9c87af1f4102dd37ec2967
BLAKE2b-256 5ba38bde208580056f3be4c59e403afecefd08d949c038218ae11e2c398029bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tfparse-0.6.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b92a0a49089b0d795f9b39f7ab6735675ffca66e71b3507b622195a5121667ee
MD5 49c45f672899a97c7b8af567e945abc5
BLAKE2b-256 e4c3c24650ed6d01967b0cf48e5821fce840df08d265a9975cfb8d9da8300c80

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