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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for tfparse-0.6.11-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c557a08305d1b10c69ddb91d6bb9a53d0b45f15de9c540a148b9548ca51e65ec |
|
MD5 | 7b00426ee98419b88ad14cff0e6512f8 |
|
BLAKE2b-256 | c0a5b743f95fef996271b535465515662d753bf12293354416e8ce66b5604021 |
Hashes for tfparse-0.6.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb21a8baed3c9d4dc9adc594e2210f0fc72a598db7a49633b937e1ad92ca69fe |
|
MD5 | 6944a868518d469ed78234f76f31b840 |
|
BLAKE2b-256 | c1b697d9738b51b31dd824ddd53d064a4fcee10125fbfad4deafe9b6e5a17771 |
Hashes for tfparse-0.6.11-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b6d88273cc7f94b1d25c309b646730ec5e96c088149e0e7634ccaa32981babe |
|
MD5 | 87e47bc9da9a4bf0bc1ee2132c2535f1 |
|
BLAKE2b-256 | fd80eb57fc14cdc0cd77dec5dfa99c9b8d00c08f782fd59d56bf6a888e65e208 |
Hashes for tfparse-0.6.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d20094d8e3f793307d4f21b1c9d17e6873f2d1c93ed1790f628c401bb7e4680 |
|
MD5 | 98b5cfa2ed67ddf2a389cd1f831523bb |
|
BLAKE2b-256 | bc1e4835ebc8c3b7e4e78a4929f49f03f464245fdb459f9dcb1c2cae010d739f |
Hashes for tfparse-0.6.11-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 704b00beaf19997827e702c42912252eeb2644ce149aec266b410ea12324f23d |
|
MD5 | 4a21cf154c230ca32c5f63c7024fb41b |
|
BLAKE2b-256 | a351ed6db1bef122c7195740ed67d70215866a9377d3b81445fcef9f00eaa3da |
Hashes for tfparse-0.6.11-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b5001d5470b8c28a2ddb15ba2ee3edbc841e4fe8897841fb0859cfbb2661c07 |
|
MD5 | e1ef1c7fe3fea0730ba499bc960f2e0a |
|
BLAKE2b-256 | 58cf2ed5c6e8c9d6dd6989208a2f6c2f0bb5c78e77168c38248a43e218794ce0 |
Hashes for tfparse-0.6.11-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed358f3542d56be1bb51e8b48b3863db93900e53a4336b9ce4f5e49d7e85e505 |
|
MD5 | 4be8b1e8495bff825dc0675495d756a7 |
|
BLAKE2b-256 | e3e011c16b29a574acbe793226c79db1b9082bd7cb0d48f50ec585fb231fcaf8 |
Hashes for tfparse-0.6.11-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc67d30f0724cd1afccd5fbbfa83892aa0c256ee778cbde58cde84b1bd0a008e |
|
MD5 | 5b0abddf5460ea3d1164f3643bb82f69 |
|
BLAKE2b-256 | 1ce8f2333dc4e318c28ba304115145ffb0357d6b584462b080e6c15a027f2a8d |
Hashes for tfparse-0.6.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2427ad2e500bb8155686c8cb4858934318e1ebf9351b87ef3f3cbf0b8fc90eb |
|
MD5 | 83e8a19a7c984ceb6e45485825a9b109 |
|
BLAKE2b-256 | 5abb32d75759e49cee175748757da84dbc339c233d122b939188c5a2358ea942 |
Hashes for tfparse-0.6.11-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ad0831c06060d99852a6986f051b8703fba845da765e153ebaedfeaf125982 |
|
MD5 | a966b36f069fa9e4f58dbb37ba490fee |
|
BLAKE2b-256 | 19060e7786b7b43317b431ff0d61f1883cd11c906442364c4ac729aaf8a98274 |
Hashes for tfparse-0.6.11-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a5ca60f206e6c9bc011a93fdb28618e10d8729807e1c998819ef26347ebc21e |
|
MD5 | 2f13242cd78c72dffa4a0ad979739a91 |
|
BLAKE2b-256 | b730228e61c5211111c6bcfe847d47ac2839fe8d3f233ce770ccd2d0e67c4f4d |
Hashes for tfparse-0.6.11-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 359ba6f13e294706cef9779bce1c13aa96b817efe921ae58aa59544b89477670 |
|
MD5 | 1de54eb93f7f7067d7ff4c49fd9985c7 |
|
BLAKE2b-256 | c585cbff09cc58c508cdd2c7be4e4038acca7abb3fe99e8581440c9e00c56c5c |
Hashes for tfparse-0.6.11-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae81264e4e5b2c12fe08fbc83d7c1b8b48e97e2a6f8ee8ae1ed3f1e8068d814c |
|
MD5 | d00318e8fa2ca49b1a895062c642053b |
|
BLAKE2b-256 | 4763bde96644285843bd155ae89311f343d8e60855da22a84a87344fe954e0ab |
Hashes for tfparse-0.6.11-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6763c8fe7cc547032dc11dcc1028e212b2f8ba749a265cbe3e017d6fffa7165 |
|
MD5 | 900e31d9cbd9a3e2bf873883441a19ef |
|
BLAKE2b-256 | f1316cdabfbdc9892ad05acf69b3f0d306661a6e2fccfecbdca1913c6e6d7def |
Hashes for tfparse-0.6.11-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c378de5015af5cb40e4629e13e72c4051bb73d2e9b4efc9919b2e964290a992 |
|
MD5 | f22e6a27644c5d95bfa433c47626a265 |
|
BLAKE2b-256 | 219baa1873966eb519d606d171ea816766200c9e90a94604b2251fc512f56167 |