Skip to content

Conversation

oyiz-michael
Copy link

@oyiz-michael oyiz-michael commented Jul 30, 2025

This change makes skipping dependency inputs the default behavior in Terragrunt, providing significant performance improvements for all users.

Description

Fixes #4589 #3873, #3013, #3538, #3934.

Closes #4601

This PR makes skipping dependency inputs the default behavior in Terragrunt, providing significant performance improvements for all users. Previously, users had to explicitly enable the skip-dependencies-inputs strict control to avoid performance penalties. Now, the deprecated dependency inputs feature is blocked by default.

Problem Statement

The dependency inputs feature (dependency.foo.inputs.bar) has been causing major performance issues:

Root Cause: When parsing dependency inputs, Terragrunt performs recursive parsing of the entire dependency tree, causing exponential slowdown with dependency depth and unnecessary state fetching.

Solution

Before: Dependency inputs parsed by default (slow) → opt-in to skip with --strict-control=skip-dependencies-inputs (fast)

After: Dependency inputs blocked by default (fast) → use dependency outputs instead (recommended)

Changes Made

Core Logic:

  • config/config.go: Block dependency inputs in detectDeprecatedConfigurations()
  • config/config_partial.go: Skip dependency input parsing by default
  • internal/strict/controls/controls.go: Update control description

Testing:

  • Updated existing tests to expect errors for dependency inputs
  • Added comprehensive unit tests (config/dependency_inputs_test.go)
  • Added integration tests to verify end-to-end behavior

Performance Impact

  • Eliminates recursive parsing overhead for dependency inputs
  • Reduces memory usage from unnecessary configuration parsing
  • Improves scalability - linear vs exponential performance with dependency depth

This change aligns with the Road to 1.0 schedule (#3535) item 6 planned for October 2025.

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)

Updated: Dependency input parsing behavior - now blocked by default for performance improvements. Users must migrate from dependency.foo.inputs.bar to dependency.foo.outputs.bar.

Migration Guide

Breaking Change: Configurations using dependency.foo.inputs.bar will now fail with a clear error message.

Before (will now fail):

dependency "vpc" {
  config_path = "../vpc"
}

inputs = {
  vpc_id = dependency.vpc.inputs.vpc_id  # ❌ Will fail
}

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Deprecated usage of reading inputs from dependencies is now blocked by default, improving performance and reliability.
  * Users attempting to use `dependency.foo.inputs` will receive a clear error message instructing them to use `dependency.foo.outputs` instead.

* **Documentation**
  * Updated warning and error messages to clarify that dependency inputs are deprecated and outputs should be used.

* **Tests**
  * Added and updated unit and integration tests to verify that deprecated dependency inputs are blocked and appropriate error messages are shown.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

This change makes skipping dependency inputs the default behavior in
Terragrunt, providing significant performance improvements for all users.
Copy link

vercel bot commented Jul 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
terragrunt-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 6:50pm

Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

📝 Walkthrough

Walkthrough

The changes remove support for reading inputs from dependencies (dependency.foo.inputs) in Terragrunt by default, making this behavior deprecated and blocked. The code now returns an immediate error when such usage is detected. Tests and documentation are updated to reflect this default, and integration/unit tests verify that the deprecated usage is blocked and outputs (dependency.foo.outputs) remain allowed.

Changes

Cohort / File(s) Change Summary
Core logic: Block dependency inputs
config/config.go, config/config_partial.go
Removes logic for parsing/allowing dependency inputs; now immediately returns an error if dependency.foo.inputs is detected. Removes related strict control checks and parsing helpers.
Strict controls documentation
internal/strict/controls/controls.go
Updates descriptions, warnings, and error messages for the SkipDependenciesInputs control to clarify that dependency inputs are deprecated and disabled by default.
Unit tests for dependency inputs
config/dependency_inputs_test.go
Adds new unit tests to verify that dependency inputs are blocked and outputs are still allowed. Tests error messaging and detection logic for deprecated usage.
Integration tests: Blocked dependency inputs
test/integration_test.go, test/integration_serial_test.go
Adds and updates integration tests to assert that configurations using dependency.foo.inputs fail by default with the correct error message, while those using outputs succeed.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TerragruntParser
    participant Logger

    User->>TerragruntParser: Parse terragrunt.hcl with dependency.foo.inputs
    TerragruntParser->>TerragruntParser: detectDeprecatedConfigurations()
    TerragruntParser-->>User: Return error "Reading inputs from dependencies is no longer supported"
    TerragruntParser->>Logger: Log deprecation message
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Make skip of dependency inputs default; block dependency.foo.inputs usage by default (#4589)
Remove recursive parsing of dependency inputs for performance (#4589)
Update tests to verify new default and error messages (#4589)
Provide migration guidance to use outputs instead of inputs (#4589)
Add --enable-dependency-inputs flag for backward compatibility (#4589) There is no evidence of an opt-out or backward compatibility flag being added in the provided changes.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
None found

Possibly related PRs

Suggested reviewers

  • levkohimins
  • denis256

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b094bc4 and 4d7d34a.

📒 Files selected for processing (6)
  • config/config.go (1 hunks)
  • config/config_partial.go (1 hunks)
  • config/dependency_inputs_test.go (1 hunks)
  • internal/strict/controls/controls.go (2 hunks)
  • test/integration_serial_test.go (1 hunks)
  • test/integration_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

⚙️ CodeRabbit Configuration File

Review the Go code for quality and correctness. Make sure that the Go code follows best practices, is performant, and is easy to understand and maintain.

Files:

  • internal/strict/controls/controls.go
  • config/config_partial.go
  • test/integration_serial_test.go
  • config/config.go
  • config/dependency_inputs_test.go
  • test/integration_test.go
🧠 Learnings (2)
📓 Common learnings
Learnt from: yhakbar
PR: gruntwork-io/terragrunt#3868
File: docs-starlight/patches/@astrojs%[email protected]:33-33
Timestamp: 2025-02-10T23:20:04.295Z
Learning: In Terragrunt projects, all `.hcl` files can be assumed to be Terragrunt configurations by default, with specific exceptions like `.terraform.lock.hcl` that need explicit handling.
config/config_partial.go (3)

Learnt from: levkohimins
PR: #3723
File: cli/commands/stack/action.go:160-160
Timestamp: 2025-02-10T13:36:19.542Z
Learning: The project uses a custom error package github.com/gruntwork-io/terragrunt/internal/errors which provides similar functionality to fmt.Errorf but includes stack traces. Prefer using this package's error functions (e.g., errors.Errorf, errors.New) over the standard library's error handling.

Learnt from: yhakbar
PR: #4169
File: cli/commands/hcl/validate/cli.go:29-60
Timestamp: 2025-04-17T13:02:28.098Z
Learning: Avoid shadowing imported packages with local variables in Go code, such as using a variable named flags when the github.com/gruntwork-io/terragrunt/cli/flags package is imported. Use more specific variable names like flagSet instead.

Learnt from: wakeful
PR: #4491
File: test/integration_test.go:4265-4265
Timestamp: 2025-07-03T22:05:07.356Z
Learning: Constants defined in one Go file are accessible from other files in the same package without explicit imports. When reviewing Go code, consider the package-level scope rather than just the individual file scope.

🔇 Additional comments (12)
test/integration_test.go (1)

3079-3116: LGTM! Well-structured integration test for the new default behavior.

This test effectively validates that the deprecated dependency.foo.inputs syntax is now blocked by default, which aligns perfectly with the PR objectives. The test implementation follows good practices:

  • Proper isolation using t.Parallel() and t.TempDir()
  • Clear test setup with realistic Terragrunt configuration
  • Appropriate error assertions checking for specific messages about dependency inputs being blocked
  • Follows the established pattern of other integration tests in the file

The test correctly verifies that users will receive a clear error message directing them to use dependency.foo.outputs instead, supporting the migration path described in the PR objectives.

config/config.go (1)

1371-1373: LGTM! Clean implementation of the default dependency inputs blocking.

The simplified logic correctly blocks deprecated dependency inputs by default, providing a clear error message that guides users to migrate to dependency outputs. This aligns perfectly with the PR's performance optimization objectives.

config/config_partial.go (1)

504-523: LGTM! Excellent implementation of dependency inputs parsing skip.

The change effectively eliminates the performance overhead by unconditionally skipping dependency input parsing while providing clear debug logging about the deprecated feature. The comments clearly explain the rationale, and the early break prevents expensive recursive parsing operations.

test/integration_serial_test.go (3)

241-241: LGTM: Correctly separated apps that use deprecated features.

The change from applying all apps ["c", "b", "a"] to only ["c", "b"] properly isolates the apps that don't use deprecated dependency inputs.


244-250: LGTM: Clear separation of non-deprecated app testing.

The logic correctly applies apps "c" and "b" first, which don't use the deprecated dependency inputs feature, ensuring they work as expected before testing the deprecated functionality.


252-267: LGTM: Proper testing of deprecated dependency inputs blocking.

The test correctly expects an error when validating app 'a' that uses dependency.foo.inputs syntax, and validates the error message contains the expected text about inputs no longer being supported and recommending outputs instead.

internal/strict/controls/controls.go (3)

38-40: LGTM: Clear documentation of the new default behavior.

The updated comment correctly reflects that dependency inputs are now disabled by default for performance, making the control's purpose clear.


68-68: LGTM: Accurate control description.

The description properly communicates that dependency inputs are deprecated and disabled by default for performance, with clear guidance to use outputs instead.


70-70: LGTM: Updated warning message reflects new default.

The warning message correctly states that dependency inputs are "now disabled by default" rather than just deprecated, providing accurate information to users.

config/dependency_inputs_test.go (3)

14-46: LGTM: Comprehensive test for blocking deprecated dependency inputs.

The test properly validates that dependency.foo.inputs syntax is blocked by default, with correct setup using HCL parsing and strict controls, and appropriate error message assertions.


48-78: LGTM: Ensures dependency outputs remain functional.

This test correctly verifies that the new blocking behavior doesn't affect the supported dependency.foo.outputs syntax, ensuring backward compatibility for the recommended approach.


80-137: LGTM: Thorough parameterized testing of detection logic.

The test suite comprehensively covers various scenarios for the detectInputsCtyUsage function including:

  • Detection of single and multiple dependency inputs
  • Non-detection of dependency outputs
  • Non-detection when no dependency references exist
    This provides excellent coverage of the detection logic.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@yhakbar
Copy link
Collaborator

yhakbar commented Jul 30, 2025

I'm leaving this in draft until we're ready to merge according to the deprecation schedule. Happy to work with you on it to make sure it's good, though!

@oyiz-michael
Copy link
Author

I'm leaving this in draft until we're ready to merge according to the deprecation schedule. Happy to work with you on it to make sure it's good, though!

Great—thanks for flagging the draft status, @yhakbar! I’ll hold off on marking it ready and continue refining the tests and docs in the meantime. Let me know if there are any specific adjustments or additional test cases you’d like me to cover before the deprecation date.

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.

Removal of behavior where inputs are read from dependencies Feature Request: Default skip of dependency inputs
2 participants