Skip to content

frostyaxe/terrapy

Repository files navigation

🌍 terrapy

terrapy is a lightweight CLI tool that automates the generation, validation, and application of Terraform templates using Python. It integrates seamlessly with the Terraform CLI and provides a programmable interface to work with infrastructure-as-code.

✨ Features

  • 🔧 Render Terraform configuration files from templates
  • ✅ Automatically validate rendered configurations
  • 📈 Visualize Terraform resource graphs
  • 🚀 Apply infrastructure changes via Terraform CLI
  • 🧩 CLI integration using frameworks like Click or Typer

📦 Requirements

Make sure you have the following installed:

  • Python 3.7+
  • Terraform CLI
  • graphviz and its Python bindings:
    sudo apt install graphviz  # Linux
    brew install graphviz      # macOS
    
    pip install graphviz
    

🛠 Usage

Render and Preview Terraform Templates

To render and validate a Terraform module, use the templates command. You can specify the module name and optionally provide a path to the variable file (terrapy.vars by default):

python main.py templates <module-name> [--vars <path-to-vars-file>]

Apply a Terraform Module

To apply a Terraform module (e.g., aws_s3_bucket), use the apply command:

python main.py apply <module-name>

📦 Custom Functions/Macros

Each macro file should define one or more Jinja2 macros.
Example: macros/greet.j2

{# hello.j2 #}
{% macro hello(name) %}
  Hello, {{ name }}!
{% endmacro %}

And then, you can use it as shown below in the jinja2 templates.

macros['hello'].hello("Alice")

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •