Skip to content

feat: add stack dependencies experiment#5809

Open
denis256 wants to merge 5 commits intomainfrom
OSS-3019
Open

feat: add stack dependencies experiment#5809
denis256 wants to merge 5 commits intomainfrom
OSS-3019

Conversation

@denis256
Copy link
Copy Markdown
Member

@denis256 denis256 commented Apr 6, 2026

Description

  • Added stack dependencies experiment

RFC: #5663

TODOs

Read the Gruntwork contribution guidelines.

  • I authored this code entirely myself
  • I am submitting code based on open source software (e.g. MIT, MPL-2.0, Apache)]
  • I am adding or upgrading a dependency or adapted code and confirm it has a compatible open source license
  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

Summary by CodeRabbit

  • New Features

    • Added the "stack-dependencies" experiment to define unit-to-unit and stack-to-stack dependencies, enabling automatic wiring of outputs and configuration overrides during stack generation.
  • Documentation

    • Published comprehensive experiment docs and changelog entry with examples, variable reference patterns, and CLI usage (e.g., run with the experiment flag).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bc9700e8-aa93-49f3-85c2-b0c09941fb6c

📥 Commits

Reviewing files that changed from the base of the PR and between b52ac37 and a8b0303.

📒 Files selected for processing (1)
  • docs/src/data/experiments/stack-dependencies.mdx
✅ Files skipped from review due to trivial changes (1)
  • docs/src/data/experiments/stack-dependencies.mdx

📝 Walkthrough

Walkthrough

Introduced a new stack-dependencies experiment that enables autoinclude blocks in terragrunt.stack.hcl files for managing stack and unit dependencies and configuration overrides. Added experiment documentation and registered the new experiment constant in the codebase.

Changes

Cohort / File(s) Summary
Documentation
docs/src/data/changelog/v1.0.1.mdx, docs/src/data/experiments/stack-dependencies.mdx
Added changelog entry and comprehensive experiment documentation for stack-dependencies, including feature description, autoinclude block syntax, variable references, dependency patterns, CLI examples, and stabilization criteria.
Experiment Registration
internal/experiment/experiment.go
Added new exported constant StackDependencies and registered it in the experiments discovery list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete: it lacks a proper description of changes, has placeholder release notes text, and provides no migration guide despite the template requiring these sections. Replace 'Added stack dependencies experiment' with detailed description of changes; fill in release notes with actual content and confirm if migration guide is needed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add stack dependencies experiment' clearly and concisely summarizes the main change—introducing a new experiment for stack dependencies.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch OSS-3019

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
terragrunt-docs Ready Ready Preview, Comment Apr 8, 2026 1:50pm

Request Review

@denis256 denis256 marked this pull request as ready for review April 6, 2026 22:22
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/src/data/changelog/v1.0.1.mdx (1)

38-38: Consider broadening the subsection title for precision.

Line 38 currently frames this as unit wiring only; the body also covers stack-level dependency behavior. A title like “Dependency wiring across units and stacks” would be clearer.
As per coding guidelines, docs should be clear and easy to follow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/src/data/changelog/v1.0.1.mdx` at line 38, Update the subsection title
currently written as `stack-dependencies` to a clearer, broader heading that
reflects both unit and stack-level behavior—e.g., change it to "Dependency
wiring across units and stacks" so the title matches the body content discussing
stack-level dependency behavior; update the header text where
`stack-dependencies` appears to the new phrasing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/src/data/experiments/stack-dependencies.mdx`:
- Around line 9-18: Update the documentation for the `stack-dependencies`
experiment to clarify that `terragrunt.autoinclude.hcl` is deep-merged into both
unit and stack configurations (not just unit configurations); edit the sentence
that currently reads “Automatic deep merge of `terragrunt.autoinclude.hcl` into
unit configurations (autoinclude wins)” to explicitly say “Automatic deep merge
of `terragrunt.autoinclude.hcl` into unit and stack configurations (autoinclude
wins)” so it references both targets and preserves the “autoinclude wins”
precedence.

---

Nitpick comments:
In `@docs/src/data/changelog/v1.0.1.mdx`:
- Line 38: Update the subsection title currently written as `stack-dependencies`
to a clearer, broader heading that reflects both unit and stack-level
behavior—e.g., change it to "Dependency wiring across units and stacks" so the
title matches the body content discussing stack-level dependency behavior;
update the header text where `stack-dependencies` appears to the new phrasing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9412263e-b62a-43cb-a205-d55a6fc51abe

📥 Commits

Reviewing files that changed from the base of the PR and between 6912793 and b52ac37.

📒 Files selected for processing (3)
  • docs/src/data/changelog/v1.0.1.mdx
  • docs/src/data/experiments/stack-dependencies.mdx
  • internal/experiment/experiment.go

Comment on lines +9 to +18
### `stack-dependencies` - What it does
When enabled, this experiment adds support for the `autoinclude` block nested inside `unit` and `stack` blocks in `terragrunt.stack.hcl` files. The `autoinclude` block allows users to define `dependency` blocks and arbitrary configuration that gets generated into a `terragrunt.autoinclude.hcl` file during stack generation. This file is automatically merged into the unit/stack configuration when parsed.

This experiment enables:

- **`unit.<name>.path`** and **`stack.<name>.path`** variables in `terragrunt.stack.hcl` for referencing sibling component paths
- **`stack.<name>.<unit_name>.path`** for referencing individual units within a nested stack (fine-grained dependency)
- **`dependency` blocks targeting stack directories** — aggregated outputs from all units in the stack (`dependency.stack_name.outputs.unit_name.output_key`)
- **Automatic deep merge** of `terragrunt.autoinclude.hcl` into unit configurations (autoinclude wins)
- **Stack dependency expansion** in the run queue — depending on a stack blocks until all its units complete
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify merge target to include stack configs at Line 17.

Line 17 currently says deep merge into unit configurations only, but this experiment behavior applies to both unit and stack configurations.

✏️ Proposed doc fix
-- **Automatic deep merge** of `terragrunt.autoinclude.hcl` into unit configurations (autoinclude wins)
+- **Automatic deep merge** of `terragrunt.autoinclude.hcl` into unit and stack configurations (autoinclude wins)

As per coding guidelines, this doc must state that terragrunt.autoinclude.hcl is deep-merged into unit/stack config with “autoinclude wins” precedence.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### `stack-dependencies` - What it does
When enabled, this experiment adds support for the `autoinclude` block nested inside `unit` and `stack` blocks in `terragrunt.stack.hcl` files. The `autoinclude` block allows users to define `dependency` blocks and arbitrary configuration that gets generated into a `terragrunt.autoinclude.hcl` file during stack generation. This file is automatically merged into the unit/stack configuration when parsed.
This experiment enables:
- **`unit.<name>.path`** and **`stack.<name>.path`** variables in `terragrunt.stack.hcl` for referencing sibling component paths
- **`stack.<name>.<unit_name>.path`** for referencing individual units within a nested stack (fine-grained dependency)
- **`dependency` blocks targeting stack directories** — aggregated outputs from all units in the stack (`dependency.stack_name.outputs.unit_name.output_key`)
- **Automatic deep merge** of `terragrunt.autoinclude.hcl` into unit configurations (autoinclude wins)
- **Stack dependency expansion** in the run queue — depending on a stack blocks until all its units complete
### `stack-dependencies` - What it does
When enabled, this experiment adds support for the `autoinclude` block nested inside `unit` and `stack` blocks in `terragrunt.stack.hcl` files. The `autoinclude` block allows users to define `dependency` blocks and arbitrary configuration that gets generated into a `terragrunt.autoinclude.hcl` file during stack generation. This file is automatically merged into the unit/stack configuration when parsed.
This experiment enables:
- **`unit.<name>.path`** and **`stack.<name>.path`** variables in `terragrunt.stack.hcl` for referencing sibling component paths
- **`stack.<name>.<unit_name>.path`** for referencing individual units within a nested stack (fine-grained dependency)
- **`dependency` blocks targeting stack directories** — aggregated outputs from all units in the stack (`dependency.stack_name.outputs.unit_name.output_key`)
- **Automatic deep merge** of `terragrunt.autoinclude.hcl` into unit and stack configurations (autoinclude wins)
- **Stack dependency expansion** in the run queue — depending on a stack blocks until all its units complete
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/src/data/experiments/stack-dependencies.mdx` around lines 9 - 18, Update
the documentation for the `stack-dependencies` experiment to clarify that
`terragrunt.autoinclude.hcl` is deep-merged into both unit and stack
configurations (not just unit configurations); edit the sentence that currently
reads “Automatic deep merge of `terragrunt.autoinclude.hcl` into unit
configurations (autoinclude wins)” to explicitly say “Automatic deep merge of
`terragrunt.autoinclude.hcl` into unit and stack configurations (autoinclude
wins)” so it references both targets and preserves the “autoinclude wins”
precedence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants