### Install NPM Dependencies Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/README.md After installing with mise, run this command to install the project's NPM dependencies. ```bash bun i ``` -------------------------------- ### Install Dependencies with Mise Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/README.md Use this command to install the necessary dependencies for running the project locally. ```bash mise install ``` -------------------------------- ### Start Development Server Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/README.md Starts a local development server at http://127.0.0.1:4321. The server automatically reloads on documentation changes. ```bash bun dev ``` -------------------------------- ### Terragrunt Graph Plan Example Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/flags/graph.mdx Demonstrates the execution order when running 'terragrunt run --graph plan' in the 'eks' module. The output shows modules grouped by execution order, starting with the 'eks' module and progressing through its dependents. ```text Group 1 - Module project/eks Group 2 - Module project/services/eks-service-1 - Module project/services/eks-service-2 Group 3 - Module project/services/eks-service-2-v2 - Module project/services/eks-service-3 - Module project/services/eks-service-5 Group 4 - Module project/services/eks-service-3-v2 - Module project/services/eks-service-4 Group 5 - Module project/services/eks-service-3-v3 ``` -------------------------------- ### Start Catalog with Parent Configuration Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/catalog.mdx Launches the catalog TUI, automatically discovering configurations from a parent Terragrunt setup. This is the default behavior when no specific root file is indicated. ```bash terragrunt catalog ``` -------------------------------- ### Install Dependencies with `mise` Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/03-setup.mdx Use `mise` to install and pin specific versions of required tools for the project. Ensure `mise` is installed and configured before running these commands. ```bash mise use terragrunt@0.95.0 mise use opentofu@1.11.1 mise use aws@2.27.63 mise use node@22.17.1 ``` -------------------------------- ### Find Resources in JSON Format Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/flags/find-json.mdx Use the --json flag with the 'find' command to get structured output. This example pipes the JSON output to 'jq' to display the first three results. ```bash $ terragrunt find --json | jq '.[:3]' [ { "type": "stack", "path": "basic" }, { "type": "unit", "path": "basic/units/chick" }, { "type": "unit", "path": "basic/units/chicken" } ] ``` -------------------------------- ### Install Tip Build of Terragrunt at Specific Commit Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Install a specific tip build of Terragrunt by providing a commit SHA to the install script. ```bash curl -sSfL --proto '=https' --tlsv1.2 https://terragrunt.com/install | bash -s -- --tip --commit ``` -------------------------------- ### Install Latest Tip Build of Terragrunt Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to install the latest tip build of Terragrunt using the official install script. ```bash curl -sSfL --proto '=https' --tlsv1.2 https://terragrunt.com/install | bash -s -- --tip ``` -------------------------------- ### Quick Install Terragrunt Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to quickly install Terragrunt on Linux or macOS. It downloads and executes the installation script. ```bash curl -sSfL --proto '=https' --tlsv1.2 https://terragrunt.com/install | bash ``` -------------------------------- ### Inspect and Install Terragrunt Script Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Review the installation script before execution by downloading it, inspecting it, and then running it manually. This is a safer alternative to piping directly to bash. ```bash curl -sSfL --proto '=https' --tlsv1.2 -o install.sh https://terragrunt.com/install less install.sh bash install.sh ``` -------------------------------- ### Install Terragrunt with Pkg on FreeBSD Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to install Terragrunt on FreeBSD via Pkg. ```bash pkg install terragrunt ``` -------------------------------- ### Install Git Pre-commit Hook for Formatting Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/05-community/01-contributing.mdx Run 'make install-pre-commit-hook' to install a git pre-commit hook. This hook automatically formats all staged source files with gofmt before each commit. ```bash make install-pre-commit-hook ``` -------------------------------- ### Install Terragrunt with Emerge on Gentoo Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to install Terragrunt on Gentoo via emerge. ```bash emerge -a app-admin/terragrunt-bin ``` -------------------------------- ### Install Terragrunt with asdf Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Install Terragrunt using the asdf version manager. This involves adding the plugin and then installing a specific version. Replace `${version}` with the desired Terragrunt version. ```bash asdf plugin add terragrunt asdf install terragrunt ${version} ``` -------------------------------- ### Manual Install: Specific Commit Tip Build Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Manually install a Terragrunt tip build from a specific commit. This process includes downloading the specified commit's archive, verifying its checksum, extracting, and installing it. Remember to set the COMMIT, OS, and ARCH variables. ```bash set -euo pipefail # Set the commit SHA, platform, and architecture COMMIT="abc123def456" OS="linux" ARCH="amd64" ARCHIVE="terragrunt_${OS}_${ARCH}.tar.gz" # Download the archive and checksums curl -sL -o "$ARCHIVE" "https://builds.terragrunt.com/api/v1/tip/${COMMIT}/download?os=${OS}&arch=${ARCH}" curl -sL -o SHA256SUMS "https://builds.terragrunt.com/api/v1/tip/${COMMIT}/download?filename=SHA256SUMS" # Verify checksum EXPECTED=$(awk -v f="$ARCHIVE" '$2 == f {print $1; exit}' SHA256SUMS) ACTUAL=$(sha256sum "$ARCHIVE" | awk '{print $1}') # macOS: use "shasum -a 256" if [ "$EXPECTED" != "$ACTUAL" ]; then echo "Checksum verification failed!" exit 1 fi echo "Checksum verified!" # Extract and install tar -xzf "$ARCHIVE" chmod +x "terragrunt_${OS}_${ARCH}" sudo mv "terragrunt_${OS}_${ARCH}" /usr/local/bin/terragrunt ``` -------------------------------- ### Build Terragrunt from Source Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Clone the Terragrunt repository and use `go install` to build the executable from source. This is useful for development or testing unreleased changes. ```shell git clone https://github.com/gruntwork-io/terragrunt.git cd terragrunt # Feel free to checkout a particular tag, etc if you want here. go install ``` -------------------------------- ### Start Jaeger with Docker Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/06-troubleshooting/02-open-telemetry.md Starts a Jaeger instance with OTLP enabled, making it accessible for Terragrunt trace collection. Ensure the UI is available at http://localhost:16686/. ```bash docker run --rm --name jaeger -e COLLECTOR_OTLP_ENABLED=true -p 16686:16686 -p 4317:4317 -p 4318:4318 jaegertracing/all-in-one:1.54.0 ``` -------------------------------- ### Example .terragrunt-catalog-ignore file Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/06-catalog/02-tui.mdx This example demonstrates how to use patterns in a `.terragrunt-catalog-ignore` file to exclude directories and specific subpaths from catalog discovery. It shows how to ignore an entire directory and its contents, as well as how to re-include a specific path that was previously excluded. ```plaintext # .terragrunt-catalog-ignore # Keep examples out of the catalog. examples examples/** # Skip everything under test/ except test/keep. test/** !test/keep ``` -------------------------------- ### Terragrunt Configuration for Production Environment Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/08-step-5-adding-terragrunt.mdx Example Terragrunt configuration file for a production environment, similar to the dev setup but with distinct naming conventions. ```hcl # live/prod/terragrunt.hcl terraform { source = "../../catalog/modules//best_cat" } inputs = { name = "best-cat-2025-09-24-2359" lambda_zip_file = "${get_repo_root()}/dist/best-cat.zip" } ``` -------------------------------- ### Create Live Directory Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/04-step-1-starting-the-terralith.mdx Create a dedicated 'live' directory for provisioning infrastructure. This is a recommended best practice for separating reusable infrastructure patterns. ```bash mkdir live ``` -------------------------------- ### Enable legacy backend provisioning with `--backend-bootstrap` Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/08-migrate/03-cli-redesign.md To maintain the previous behavior of automatically provisioning backend resources, use the `--backend-bootstrap` flag or set the `TG_BACKEND_BOOTSTRAP` environment variable to `true`. ```bash terragrunt plan --backend-bootstrap ``` -------------------------------- ### Define Filters in a File Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/08-filter/08-filters-file.mdx Create a text file with filter expressions, one per line. Lines starting with '#' and empty lines are ignored. This example includes all modules under './subtree/' except those under './subtree/dependency/'. ```text # filters.txt ./subtree/** !./subtree/dependency/** ``` -------------------------------- ### Create Application Directory Structure Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/03-setup.mdx Set up the directory structure for the application that will be managed. This involves creating parent and child directories. ```bash mkdir -p app/best-cat cd app/best-cat ``` -------------------------------- ### Terragrunt Graph Destroy Example Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/flags/graph.mdx Illustrates the execution order for 'terragrunt run --graph destroy' in the 'eks' module. The execution is reversed compared to 'plan', starting with the most dependent modules and ending with the 'eks' module itself. ```text Group 1 - Module project/services/eks-service-2-v2 - Module project/services/eks-service-3-v3 - Module project/services/eks-service-4 - Module project/services/eks-service-5 Group 2 - Module project/services/eks-service-3-v2 Group 3 - Module project/services/eks-service-3 Group 4 - Module project/services/eks-service-1 - Module project/services/eks-service-2 Group 5 - Module project/eks ``` -------------------------------- ### Build Documentation Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/README.md Builds the documentation site, generating a 'dist' directory. This process includes checks like validating all links. ```bash bun run build ``` -------------------------------- ### List Units for 'plan' with --queue-construct-as Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/02-stacks/06-run-queue.mdx Use `--queue-construct-as` (or `--as`) to see the execution order for a specific command without running it. This example shows the order for `plan`. ```bash terragrunt list --as plan -l ``` -------------------------------- ### Configure Terragrunt Development Environment with Dev Containers Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/05-community/01-contributing.mdx This JSON configuration file sets up a Visual Studio Code development environment for contributing to Terragrunt. It specifies the Go version, integrates linters, installs VSCode extensions, includes Node.js and OpenTofu, and configures a post-creation command to start the documentation server. ```json { "name": "Terragrunt Contributing IDE", "image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm", "runArgs": ["--network=host"], "customizations": { "vscode": { "settings": { "go.lintTool": "golangci-lint", "go.lintFlags": [ "--fast" ], "markdownlint.config": { "MD013": false, "MD024": false } }, "extensions": [ "davidanson.vscode-markdownlint" ] } }, "features": { "ghcr.io/devcontainers/features/node:1": {}, "ghcr.io/robbert229/devcontainer-features/opentofu:1": {} }, "postCreateCommand": "cd docs && npm install && npm run dev" } ``` -------------------------------- ### Phased Rollout with Working Directory Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/01-units/02-includes.mdx Implement a promotion workflow by using `--working-dir` to scope updates to specific environments sequentially. This allows for progressive rollouts and manual approvals between stages. ```bash # Roll out the change to the qa environment first terragrunt run --all plan --queue-include-units-reading _env/app.hcl --working-dir qa terragrunt run --all apply --queue-include-units-reading _env/app.hcl --working-dir qa # If the apply succeeds to qa, move on to the stage environment terragrunt run --all plan --queue-include-units-reading _env/app.hcl --working-dir stage terragrunt run --all apply --queue-include-units-reading _env/app.hcl --working-dir stage # And finally, prod. terragrunt run --all plan --queue-include-units-reading _env/app.hcl --working-dir prod terragrunt run --all apply --queue-include-units-reading _env/app.hcl --working-dir prod ``` -------------------------------- ### Install Test Build of Terragrunt at Specific Commit Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Install a specific test build of Terragrunt by providing a commit SHA to the install script. ```bash curl -sSfL --proto '=https' --tlsv1.2 https://terragrunt.com/install | bash -s -- --test --commit ``` -------------------------------- ### Create Git Repository Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/03-setup.mdx Initialize a new Git repository for your project. This is the first step in organizing your Infrastructure as Code. ```bash mkdir terralith-to-terragrunt cd terralith-to-terragrunt git init ``` -------------------------------- ### Find Configurations with Dependencies and JSON Output Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/find.mdx Include dependency information in the output and format the results as JSON. ```bash terragrunt find --dependencies --format 'json' ``` -------------------------------- ### Example Migration Workflow Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/backend/migrate.mdx A common workflow for migrating state involves copying the unit, running the migration command, and then cleaning up the old unit. This ensures a safe transition. ```bash cp -R old-unit-name new-unit-name terragrunt backend migrate old-unit-name new-unit-name rm -rf old-unit-name ``` -------------------------------- ### Initialize and Apply Infrastructure Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/04-step-1-starting-the-terralith.mdx Initialize the Terraform working directory and apply the infrastructure changes. You will be prompted to confirm the apply. ```bash cd live tofu init tofu apply ``` -------------------------------- ### Include Multiple Configurations Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/04-reference/01-hcl/02-blocks.mdx Demonstrates how to include and merge configurations from multiple HCL files using the 'include' block with different merge strategies. ```hcl # root.hcl remote_state { backend = "s3" config = { bucket = "my-tofu-state" key = "${path_relative_to_include()}/tofu.tfstate" region = "us-east-1" encrypt = true dynamodb_table = "my-lock-table" } } ``` ```hcl # region.hcl locals { region = "production" } ``` ```hcl # child/terragrunt.hcl include "remote_state" { path = find_in_parent_folders("root.hcl") expose = true } include "region" { path = find_in_parent_folders("region.hcl") expose = true merge_strategy = "no_merge" } inputs = { remote_state_config = include.remote_state.remote_state region = include.region.locals.region } ``` ```hcl # child/main.tf terraform { backend "s3" {} } ``` -------------------------------- ### Initialize and Migrate State for Dev Environment Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/07-step-4-breaking-the-terralith.mdx Use `tofu init -migrate-state` to initialize the backend and copy existing state to the new S3 location for the development environment. This command prompts for confirmation before migrating. ```bash $ tofu init -migrate-state Initializing the backend... Backend configuration changed! OpenTofu has detected that the configuration specified for the backend has changed. OpenTofu will now check for existing state in the backends. Do you want to copy existing state to the new backend? Pre-existing state was found while migrating the previous "s3" backend to the newly configured "s3" backend. No existing state was found in the newly configured "s3" backend. Do you want to copy this state to the new "s3" backend? Enter "yes" to copy and "no" to start with an empty state. Enter a value: yes Successfully configured the backend "s3"! OpenTofu will automatically use this backend unless the backend configuration changes. ``` -------------------------------- ### Basic Include Configuration Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/01-units/02-includes.mdx Use `include` to reference a common configuration file, reducing repetition. Ensure the referenced file exists and is accessible. ```hcl # _env/app.hcl terraform { source = "github.com//modules.git//app?ref=v0.1.0" } dependency "vpc" { config_path = "../vpc" } dependency "mysql" { config_path = "../mysql" } inputs = { basename = "example-app" vpc_id = dependency.vpc.outputs.vpc_id subnet_ids = dependency.vpc.outputs.subnet_ids mysql_endpoint = dependency.mysql.outputs.endpoint } ``` ```hcl # qa/app/terragrunt.hcl include "root" { path = find_in_parent_folders("root.hcl") } include "env" { path = "${get_terragrunt_dir()}/../../_env/app.hcl" } inputs = { env = "qa" } ``` -------------------------------- ### Create prod directory Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/02-guides/01-terralith-to-terragrunt/07-step-4-breaking-the-terralith.mdx Create a top-level directory for the production environment within the 'live' directory. ```bash mkdir prod ``` -------------------------------- ### Install Terragrunt with Homebrew on macOS Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to install Terragrunt on macOS via Homebrew. ```bash brew install terragrunt ``` -------------------------------- ### Install Terragrunt with Chocolatey on Windows Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to install Terragrunt on Windows via Chocolatey. ```bash choco install terragrunt ``` -------------------------------- ### Error Message Example Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/changelog/v1.0.8/catalog-redesign-scaffold-path-traversal.mdx This is an example of the error message encountered during component scaffolding on macOS before the fix. ```text subdirectory component contain path traversal out of the repository ``` -------------------------------- ### Find Configurations with Reading Files and JSON Output Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/find.mdx Include the list of files read by each component in the output and format the results as JSON. ```bash terragrunt find --reading --format 'json' ``` -------------------------------- ### Create Native and JSON Plans for All Units Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/flags/json-out-dir.mdx Use the `--all` and `--out-dir` flags in conjunction with `--json-out-dir` to generate both native plan files and JSON plan files for all units in your configuration. ```bash terragrunt run --all --out-dir /tmp/all --json-out-dir /tmp/all plan ``` -------------------------------- ### Terragrunt Stack HCL Configuration Example Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/stack/generate.mdx Example of a `terragrunt.stack.hcl` file defining units with their sources and paths. ```hcl # terragrunt.stack.hcl unit "mother" { source = "units/chicken" path = "mother" } unit "father" { source = "./units/chicken" path = "father" } unit "chick_1" { source = "./units/chick" path = "chicks/chick-1" } unit "chick_2" { source = "units/chick" path = "chicks/chick-2" } ``` -------------------------------- ### Install Terragrunt with Pacman on Arch Linux Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Use this command to install Terragrunt on Arch Linux via pacman. ```bash pacman -S terragrunt ``` -------------------------------- ### List Units for 'destroy' with --queue-construct-as Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/02-stacks/06-run-queue.mdx Use `--queue-construct-as` (or `--as`) to see the execution order for a specific command without running it. This example shows the order for `destroy`. ```bash terragrunt list --queue-construct-as destroy ``` -------------------------------- ### Manual Install: Specific Commit Test Build Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Manually install a Terragrunt test build from a specific commit. This involves downloading the archive for the specified commit, verifying its checksum, extracting, and installing. Ensure COMMIT, OS, and ARCH are correctly set. ```bash set -euo pipefail # Set the commit SHA, platform, and architecture COMMIT="abc123def456" OS="linux" ARCH="amd64" ARCHIVE="terragrunt_${OS}_${ARCH}.tar.gz" BASE_URL="https://builds.terragrunt.com/test/${COMMIT}" # Download the archive and checksums curl -sL -o "$ARCHIVE" "${BASE_URL}/${ARCHIVE}" curl -sL -o SHA256SUMS "${BASE_URL}/SHA256SUMS" # Verify checksum EXPECTED=$(awk -v f="$ARCHIVE" '$2 == f {print $1; exit}' SHA256SUMS) ACTUAL=$(sha256sum "$ARCHIVE" | awk '{print $1}') # macOS: use "shasum -a 256" if [ "$EXPECTED" != "$ACTUAL" ]; then echo "Checksum verification failed!" exit 1 fi echo "Checksum verified!" # Extract and install tar -xzf "$ARCHIVE" chmod +x "terragrunt_${OS}_${ARCH}" sudo mv "terragrunt_${OS}_${ARCH}" /usr/local/bin/terragrunt ``` -------------------------------- ### Find Configurations with Queue Construct as Plan Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/find.mdx Sort configurations based on the dependency graph, simulating the order for a 'plan' command. ```bash $ terragrunt find --queue-construct-as=plan stacks/live/dev stacks/live/prod units/live/dev/vpc units/live/prod/vpc units/live/dev/db units/live/prod/db units/live/dev/ec2 units/live/prod/ec2 ``` -------------------------------- ### Tree Format Example (Default) Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/list.mdx This is an example of the default tree format output for Terragrunt configurations, showing a hierarchical structure. ```bash . ╰── live ├── dev │ ├── db │ ├── ec2 │ ╰── vpc ╰── prod ├── db ├── ec2 ╰── vpc ``` -------------------------------- ### Terragrunt Configuration Example Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/06-troubleshooting/01-debugging.mdx Example Terragrunt configuration defining local variables and dependencies, used to illustrate input debugging. ```hcl locals { image_id = "acme/myapp:1" } dependency "cluster" { config_path = "../ecs-cluster" } inputs = { image_id = locals.image_id num_tasks = dependency.cluster.outputs.cluster_min_size } ``` -------------------------------- ### Run Go Benchmark Tests with Memory Allocation Info Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/06-troubleshooting/03-performance.mdx Extend benchmark tests to include memory allocation profiling. This provides insights into memory usage patterns and helps in optimizing memory-intensive operations. ```shell go test -bench=BenchmarkSomeFunction -benchmem ``` -------------------------------- ### Start Catalog with Explicit Root File Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/catalog.mdx Launches the catalog TUI and explicitly specifies the Terragrunt configuration file to use as the root for discovery. Use this when your root configuration file has a non-standard name. ```bash terragrunt catalog --root-file-name root.hcl ``` -------------------------------- ### Install Terragrunt Autocomplete Package Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Installs the autocomplete package for Terragrunt commands. This command should be run after ensuring the shell configuration file exists. ```shell terragrunt --install-autocomplete ``` -------------------------------- ### Build the Flake Utility Source: https://github.com/gruntwork-io/terragrunt/blob/main/test/flake/README.md Build the CLI tool from source. Ensure you are in the 'test/flake' directory. ```bash cd test/flake go build -o flake . ``` -------------------------------- ### Install Terragrunt with mise Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/01-getting-started/03-install.mdx Install a specific version of Terragrunt using the mise tool manager. Replace `${version}` with the desired Terragrunt version. ```bash mise install terragrunt ${version} ``` -------------------------------- ### Example Excludes File Content Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/flags/queue-excludes-file.mdx This is an example of the content expected in the file specified by the `--queue-excludes-file` flag. Each line represents a directory to be excluded. ```text # excludes-file.txt prod ``` -------------------------------- ### Download Latest Tip Build by Filename Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/07-process/03-releases.mdx Use this command to download a specific file (e.g., SHA256SUMS) from the latest tip build. The -L flag ensures that redirects are followed. ```bash curl -L -o SHA256SUMS \ "https://builds.terragrunt.com/api/v1/tip/latest/download?filename=SHA256SUMS" ``` -------------------------------- ### Using --queue-include-dir vs --filter Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/flags/queue-include-dir.mdx Demonstrates how the --queue-include-dir flag is equivalent to using the --filter flag with a specific expression. Use --queue-include-dir for clarity when targeting directories. ```bash terragrunt run --all --queue-include-dir "prod/**" -- plan ``` ```bash terragrunt run --all --filter "{./prod/**}" -- plan ``` -------------------------------- ### Respecting --download-dir Across Dependencies Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/changelog/v1.0.5/download-dir-dependency-blocks.mdx This example demonstrates the previous behavior where `--download-dir` was not fully respected. The root unit's outputs were correctly placed, but dependency outputs fell back to the default cache location. ```sh TG_DOWNLOAD_DIR=/tmp/tg-cache terragrunt run --all plan # Root unit: outputs landed in /tmp/tg-cache ✓ # Dependency outputs: written next to each dependency's terragrunt.hcl ✗ ``` -------------------------------- ### Example JSON Run Report Format Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/02-stacks/07-run-report.mdx This is an example of the JSON format for the Terragrunt run report. It provides structured data for each unit run, omitting empty fields. ```json [ { "Name": "first-exclude", "Started": "2025-06-05T16:28:41-04:00", "Ended": "2025-06-05T16:28:41-04:00", "Result": "excluded", "Reason": "exclude block" }, { "Name": "first-success", "Started": "2025-06-05T16:28:41-04:00", "Ended": "2025-06-05T16:28:41-04:00", "Result": "succeeded" } ] ``` -------------------------------- ### Example CSV Run Report Format Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/03-features/02-stacks/07-run-report.mdx This is an example of the CSV format for the Terragrunt run report. It includes details for each unit run, such as name, timestamps, result, and reason. ```csv Name,Started,Ended,Result,Reason,Cause first-exclude,2025-06-05T16:28:41-04:00,2025-06-05T16:28:41-04:00,excluded,exclude block, second-exclude,2025-06-05T16:28:41-04:00,2025-06-05T16:28:41-04:00,excluded,exclude block, first-failure,2025-06-05T16:28:41-04:00,2025-06-05T16:28:42-04:00,failed,run error, first-success,2025-06-05T16:28:41-04:00,2025-06-05T16:28:41-04:00,succeeded,, second-failure,2025-06-05T16:28:41-04:00,2025-06-05T16:28:42-04:00,failed,run error, second-success,2025-06-05T16:28:41-04:00,2025-06-05T16:28:41-04:00,succeeded,, second-early-exit,2025-06-05T16:28:42-04:00,2025-06-05T16:28:42-04:00,early exit,run error, first-early-exit,2025-06-05T16:28:42-04:00,2025-06-05T16:28:42-04:00,early exit,run error, ``` -------------------------------- ### Example Repository Structure with Terragrunt Stacks Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/08-migrate/04-terragrunt-stacks.mdx Illustrates a typical repository structure after organizing infrastructure into Terragrunt Stacks, highlighting the placement of `.gitignore` and `terragrunt.stack.hcl` files. ```tree - non-prod - us-east-1 - stateful-ec2-asg-service - **.gitignore** - terragrunt.stack.hcl ``` -------------------------------- ### Find Configurations with External Dependencies and JSON Output Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/find.mdx Include external dependencies in the output and format the results as JSON. ```bash terragrunt find --dependencies --external --format 'json' ``` -------------------------------- ### Example Ingress Resource for ALB Source: https://github.com/gruntwork-io/terragrunt/blob/main/internal/services/catalog/module/testdata/find_modules/modules/eks-alb-ingress-controller/README.md This is an example of an Ingress resource that can be used with the ALB Ingress Controller. It includes the necessary annotation to specify the ingress class and defines routing rules. ```yaml --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: service-ingress annotations: kubernetes.io/ingress.class: alb spec: rules: - http: paths: - path: /service backend: serviceName: backend servicePort: 80 ``` -------------------------------- ### Example OpenTofu Compatibility API Response Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/content/docs/04-reference/05-supported-versions.mdx This is an example of the JSON response format when querying the OpenTofu compatibility API. It shows the tool, version pattern, and compatible Terragrunt version range. ```json [ { "tool": "opentofu", "version": "1.11.x", "terragrunt_min": "0.95.0", "terragrunt_max": null } ] ``` -------------------------------- ### Run a Basic Command Source: https://github.com/gruntwork-io/terragrunt/blob/main/docs/src/data/commands/run.mdx Execute a basic command like 'plan' using the `run` command. This is a more explicit alternative to direct command execution. ```bash terragrunt run plan # Shortcut: # terragrunt plan ```