Skip to main content

generate terragrunt manifest from terraform module.

Project description

🚀 terragrunt-generator 🎉

codecov

🪄 What is terragrunt-generator?

terragrunt-generator is your one-stop tool to automatically generate terragrunt.hcl files with well-documented inputs from variables exposed by Terraform modules. The magic happens with a simple YAML configuration file, making your setup process as smooth as butter! 🧈✨

📋 Requirements

  • Python 3.6+

🔧 Installation

pip install terragrunt-generator

🎯 Usage

🔍 Command Overview

terragrunt-generator --help

You'll see something like this:

usage: terragrunt-generator [-h] [-V] -u URL [-v VERSION] [-p PATH]
                            [--include | --no-include] -l LOOKUP [-o OUTPUT]
                            [--yaml-output YAML_OUTPUT]
                            [--yaml-for-env YAML_FOR_ENV]
                            [--enabled | --no-enabled]

Generate a terragrunt.hcl configuration file from a Terraform module.

options:
  -h, --help            show this help message and exit
  -V                    show program's version number and exit
  -u URL, --url URL     URL or local path to the Terraform module (can be a
                        git repo or directory).
  -v VERSION, --version VERSION
                        Branch, tag, or commit hash to checkout if the module
                        is from a git repository (default: main).
  -p PATH, --path PATH  Relative path to the module inside the repository or
                        directory (if needed).
  --include, --no-include
                        Whether to include the "include" block in the
                        generated terragrunt.hcl (default: true).
  -l LOOKUP, --lookup LOOKUP
                        Path used for variable lookup in the generated
                        Terragrunt configuration.
  -o OUTPUT, --output OUTPUT
                        File path to write the generated terragrunt.hcl
                        (default: print to stdout).
  --yaml-output YAML_OUTPUT
                        Directory to write the generated YAML config file (it
                        will be merged if it already exists).
  --yaml-for-env YAML_FOR_ENV
                        Environment name used to generate the YAML file (e.g.,
                        config.dev.yaml).
  --enabled, --no-enabled
                        Whether to mark the module as enabled in the YAML
                        configuration (default: true).

📚 Example Usage

terragrunt-generator \
-u https://github.com/terraform-google-modules/terraform-google-project-factory.git \
-v v14.2.1 \
-l 'project'

📝 Sample Output

# terraform-google-modules v14.2.1
# https://github.com/terraform-google-modules/terraform-google-project-factory/tree/v14.2.1/

include {
    path = find_in_parent_folders()
}

locals {
    source = "github.com/terraform-google-modules/terraform-google-project-factory.git?ref=v14.2.1"
    all = merge(
        yamldecode(file(find_in_parent_folders("config.yaml"))),
    )
}

terraform {
    source = lookup(local.all, "project", false) == false ? null : lookup(local.all.project, "enabled", false) == false ? null : local.source
}

inputs = merge({
    billing_account = lookup(local.all.project, "billing_account", "")
    name = lookup(local.all.project, "name", "")
    org_id = lookup(local.all.project, "org_id", "")
    activate_api_identities = lookup(local.all.project, "activate_api_identities", [])
    activate_apis = lookup(local.all.project, "activate_apis", ["compute.googleapis.com"])
})

🙌 Contribute

Got a cool idea? Found a bug? Contributions are welcome! Check out our contributing guidelines and help make terragrunt-generator even better! 🚀


Enjoy automating your Terragrunt configurations with ease! 🎉

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terragrunt_generator-0.17.1.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terragrunt_generator-0.17.1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file terragrunt_generator-0.17.1.tar.gz.

File metadata

  • Download URL: terragrunt_generator-0.17.1.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for terragrunt_generator-0.17.1.tar.gz
Algorithm Hash digest
SHA256 5088806ae1c7058094b0c7f9d0bad8721002547ed1d5bfdae14b6152a3863fd9
MD5 af4476c50a60feb64e4c4c156311d82e
BLAKE2b-256 2b3e41611512469403cb1d6f4187001516d62a29e41777f9999455c5aec658e6

See more details on using hashes here.

File details

Details for the file terragrunt_generator-0.17.1-py3-none-any.whl.

File metadata

File hashes

Hashes for terragrunt_generator-0.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a23285107110a07921f4e7918f5f0f4dc33b2f70a4d5f4e7f17d9194b4494df3
MD5 5c92c99332a4f0c91cc32d817c4cbe78
BLAKE2b-256 03b190c5528d8c35e7bfce05a105b4261ee5bbfff83bb51b1a5c582b2b454210

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page