https://github.com/rgreinho/tfpy
  
  
    Create Terraform resources using Python 
    https://github.com/rgreinho/tfpy
  
python terraform
        Last synced: 8 months ago 
        JSON representation
    
Create Terraform resources using Python
- Host: GitHub
 - URL: https://github.com/rgreinho/tfpy
 - Owner: rgreinho
 - License: mit
 - Created: 2020-04-21T19:30:52.000Z (over 5 years ago)
 - Default Branch: master
 - Last Pushed: 2020-06-28T20:42:07.000Z (over 5 years ago)
 - Last Synced: 2025-02-28T07:02:02.158Z (8 months ago)
 - Topics: python, terraform
 - Language: Python
 - Homepage: http://rgreinho.github.io/tfpy/
 - Size: 290 KB
 - Stars: 3
 - Watchers: 4
 - Forks: 1
 - Open Issues: 0
 - 
            Metadata Files:
            
- Readme: README.rst
 - Changelog: CHANGELOG.md
 - License: LICENSE
 
 
Awesome Lists containing this project
README
          tfpy
====
.. image:: https://github.com/rgreinho/tfpy/workflows/ci/badge.svg
   :target: https://github.com/rgreinho/tfpy/actions?query=workflow%3Aci
.. image:: https://badge.fury.io/py/tfpy.svg
   :target: https://badge.fury.io/py/tfpy
Create Terraform resources using Python.
Description
-----------
``tfpy`` is a thin wrapper around `terraformpy`_, aiming at providing a well defined
structure to organize your `terraform`_ stacks and leverage the power of Python to
define them rather than using `HCL`_.
The goal is to have a repository layout inspired from `Ansible `_
where the stacks are driven by the variables.
For more information regarding how to create your stacks, please refer to the official
`terraformpy`_ documentation.
Installation
------------
tfpy requires Python 3.7+ to work
::
  pip install tfpy
Usage
-----
The ``tfpy`` command needs to be run at the root of your project.
The output will be created in a new subfolder within your project, named ``generated``.
For instance ``generated/gke/production/main.tf.json``
Project layout
^^^^^^^^^^^^^^
::
  .
  ├── generated
  │   └── commerce
  │       └── staging
  │           └── main.tf.json
  ├── library
  │   ├── backend.py
  │   └── provider.py
  ├── stacks
  │   └── commerce
  │       ├── README.md
  │       ├── gke.tf.py
  │       └── terraform.tf.py
  └── vars
      ├── all
      │   ├── cartigan.yml
      │   └── config.yml
      └── staging
          └── commerce
              ├── gke.yml
              └── project.yml
* ``generated``: folder where the stack are stored as JSON once generated.
* ``library``: folder where you can place custom functions.
* ``stacks``: the stacks created using TerraformPy.
* ``vars``: the variables used to create the stacks.
Examples
^^^^^^^^
Build a project stack without an environment::
  tfpy generate organization
Build a project stack for a specific environment::
  tfpy generate gke production
.. _HCL: https://github.com/hashicorp/hcl
.. _terraform: https://www.terraform.io
.. _terraformpy: https://github.com/NerdWalletOSS/terraformpy