Giter VIP home page Giter VIP logo

tfparse's Introduction

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).

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.