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.0.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.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for terragrunt_generator-0.17.0.tar.gz
Algorithm Hash digest
SHA256 7fd08ee9bccc293d0ff922c046c7a41b441c2dc6d18794f1d3beb4aa9e8a0abf
MD5 3de9cad2888775cdc6c667008e2c408c
BLAKE2b-256 2f0a681f4d7c8a4635c2625a95d5ced3462b8a0bc89a8f25c15c5fa91a95f26e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for terragrunt_generator-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b07f7c5977714751a40db51a8f01bffcb7c9030bb7c9589f2e723ebb0038b7a6
MD5 f15139f07558ff54c76a30fe809bb923
BLAKE2b-256 aac62559d850160b8468dc820571f2df1230bc34251beb34d3aebb34a0d67bd7

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