Skip to content

Conversation

@denis256
Copy link
Member

@denis256 denis256 commented Aug 19, 2025

Description

  • Disabled state backend provisioning
  • Updated documentation
  • Tests update
  • Error in case when the remote state bucket is not available
image

Fixes #4598.

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

    • Backend provisioning is now explicit: use --backend-bootstrap or the backend bootstrap command to create/update remote state backends on demand.
  • Documentation

    • Docs updated to emphasize on-demand backend bootstrapping; removed legacy backend-require-bootstrap docs and updated strict-controls and CLI migration guidance.
  • Tests

    • Integration tests updated to use --backend-bootstrap; legacy bootstrap test removed and minor test renames applied.
  • Bug Fixes

    • Improved error explanations for missing remote state buckets, advising --backend-bootstrap.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

📝 Walkthrough

Walkthrough

Replaces strict-control–gated backend auto-provisioning with an explicit --backend-bootstrap flow: run.go now queries remoteState.NeedsBootstrap and uses BackendBootstrap/command-state presence to decide bootstrapping; docs and tests updated to use --backend-bootstrap; error messages enhanced for missing remote-state buckets.

Changes

Cohort / File(s) Summary
Run control flow
cli/commands/run/run.go
Added remoteStateNeedsInit which checks BackendBootstrap flag, presence of remote_state, whether the Terraform command uses state, and calls remoteState.NeedsBootstrap; removed prior StrictControls-based bootstrap enforcement.
Strict controls metadata
internal/strict/controls/controls.go
Marked the require-explicit-bootstrap control as completed (status changed to Completed) during control initialization.
Error explanations
shell/error_explainer.go
Added regex mappings for remote-state bucket-not-found errors that recommend manual creation or rerunning with --backend-bootstrap.
Docs: terminology & reference
docs-starlight/src/content/docs/01-getting-started/04-terminology.md, docs-starlight/src/content/docs/04-reference/03-strict-controls.mdx
Reworded state/backend wording to reflect on-demand tooling; moved/marked require-explicit-bootstrap control as completed and updated legacy notes.
Docs: commands & flags
docs-starlight/src/data/commands/run.mdx, docs-starlight/src/data/flags/backend-require-bootstrap.mdx, docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md
Removed references and file for the backend-require-bootstrap flag and updated the CLI flag migration table to mark the related flag as removed/explicit provisioning.
Integration tests: AWS
test/integration_aws_test.go, test/integration_aws_oidc_test.go, test/integration_s3_encryption_test.go
Replaced --strict-control require-explicit-bootstrap with --backend-bootstrap across commands; added --backend-bootstrap to many test invocations; removed legacy bootstrap test and fixed two test names; minor stdout/stderr concatenation tweak.
Integration tests: GCP
test/integration_gcp_test.go, test/integration_serial_gcp_test.go
Removed strict-control flag usage and added --backend-bootstrap to apply/run/migrate/delete flows and related test args.
Integration tests: misc
test/integration_docs_aws_test.go, test/integration_download_test.go, test/integration_hooks_test.go
Added --backend-bootstrap to docs test; renamed download fixture constant; converted a named import alias to a plain import in hooks test.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant TG as Terragrunt
  participant RS as remoteState
  participant TF as Terraform
  participant EE as ErrorExplainer

  U->>TG: terragrunt run/apply [--backend-bootstrap]
  TG->>TG: remoteStateNeedsInit(ctx, opts)
  alt BackendBootstrap disabled OR no remote_state OR cmd doesn't use state
    TG-->>TG: skip bootstrap
  else
    TG->>RS: NeedsBootstrap(ctx, logger, opts)
    alt bootstrap needed
      TG->>RS: Bootstrap(...)
      RS-->>TG: success/failure
    else not needed
      TG-->>TG: proceed
    end
  end
  TG->>TF: invoke Terraform
  TF-->>TG: error (e.g., bucket not found)
  TG->>EE: ExplainError(err)
  EE-->>TG: "Remote state bucket not found… rerun with --backend-bootstrap"
  TG-->>U: output / error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
Removal of backend provisioning as default behavior (#4598)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Rename test constant for download fixture (test/integration_download_test.go) Simple identifier rename/typo fix; not related to backend provisioning objectives.
Change import alias to plain import (test/integration_hooks_test.go) Import style change only; unrelated to backend bootstrap objective.
stdout/stderr concatenation tweak (test/integration_s3_encryption_test.go) Test output capture formatting change unrelated to backend bootstrap behavior.

Possibly related PRs

Suggested reviewers

  • levkohimins
  • wakeful

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 09fec57 and a3f473b.

📒 Files selected for processing (1)
  • test/integration_aws_oidc_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/integration_aws_oidc_test.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Pull Request has non-contributor approval
  • GitHub Check: lint / lint
  • GitHub Check: license_check / License Check
  • GitHub Check: Pull Request has non-contributor approval
  • GitHub Check: build-and-test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-4598

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@vercel
Copy link

vercel bot commented Aug 19, 2025

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

Project Deployment Preview Comments Updated (UTC)
terragrunt-docs Ready Ready Preview Comment Sep 5, 2025 4:07pm

@denis256 denis256 changed the title chore: disable of default backend initialization chore: disable of default backend provisioning Aug 19, 2025
denis256 and others added 8 commits September 5, 2025 15:29
* Group tests update

* Added checking for group tests

* chore: lint fixes

* runner-pool handling of TestOutputModuleGroups
* Bypass partytown

* GTM in header
* Tighten up sidebar.

* Standardize CSS ordering between dev and prod.

Previously, the site would render one way in prod and another in dev! The issue was that vite was tree-shaking CSS and wound up re-ordering things in a way it thought was permissible, whereas in dev, without that optimization, the CSS was actuallys sequenced differently.

This led to a noticable huge margin in dev, but not in prod.

This commit asserts the official ordering the CSS layers, and then adds a fix for the left-margin issue. This should now standard dev and prod.

* Reduce code font-size from 16px to 14px.

* Improve main paragraph text rendering.

Use more readable line height and paragraph separation.

* Improve spacing after file tree.

* Fix sidebar inconsistencies on 3rd level of nav.
* feat: Finalizing topological generation of stacks

* feat: Adding tests for topological stack generation

* fix: Address race condition in warning suppression

* feat: Set name of test to `TestStackGenerationWithNestedTopologyWithRacing` to ensure it's caught by race test

* feat: Adding extra generate at the end for confirmation

* fix: Updating expected log messages in tests
* test: Attempting to reproduce issue with OIDC

* fix: Fixing `get_aws_account_id()` when using AuthProviderCmd

* fix: Addressing lint findings

* fix: Adding fixture for backend with OIDC

* fix: Adding integration test for OIDC with backend

* fix: Consolidating logic for AWS credential acquisition

* fix: Addressing lint findings

* test: Removing cleanup to fix this

* fix: Fixing delete bucket cleanup

* fix: Fixing role assumption when env creds aren't fetched from auth provider

* fix: Removing unnecessary debug

* fix: Skipping failing test for now

* Fixed failing OIDC tests

* Tests cleanup

* chore: aws helper complexity reduction

* Updated cleanup order

* enabled build tags

---------

Co-authored-by: Denis O <[email protected]>
* Group tests update

* Added checking for group tests

* chore: lint fixes

* runner-pool handling of TestOutputModuleGroups

* Updated plan path save file

* Improved FAIL errors

* IsExperimentMode() simplification

* Discovery include flags

* Added passing of discovery include/exclude directories

* Fixed discovery flags passing

* Improved parsing of tests
Copy link
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 (3)
docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md (3)

77-79: Double-check flag naming consistency: “exclude” vs “excludes”.

The pair

  • --queue-exclude-dir
  • --queue-excludes-file

mixes singular vs plural. If this is not intentional, align both to the correct canonical names from the CLI.


79-79: Link users to the new bootstrap flow instead of a bare “removed”.

Make the migration path explicit and discoverable with links.

-| `--terragrunt-fail-on-state-bucket-creation`      | removed (no equivalent; backend provisioning is explicit) |
+| `--terragrunt-fail-on-state-bucket-creation`      | removed; use [`--backend-bootstrap`](/docs/reference/cli/commands/run/#backend-bootstrap) or [`backend bootstrap`](/docs/reference/cli/commands/backend/bootstrap/) |

103-106: Add missing mapping for non-interactive (mentioned above in examples).

The doc earlier advises switching to --non-interactive, but this row is not in the table that claims to be comprehensive. Add it near the other “n*” flags.

 | `--terragrunt-modules-that-include`               | `--units-that-include`                                    |
+| `--terragrunt-non-interactive`                    | `--non-interactive`                                       |
 | `--terragrunt-no-auto-approve`                    | `--no-auto-approve`                                       |
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 29a514d and d817f33.

📒 Files selected for processing (1)
  • docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs-starlight/**/*.md*

⚙️ CodeRabbit configuration file

Review the documentation for clarity, grammar, and spelling. Make sure that the documentation is easy to understand and follow. There is currently a migration underway from the Jekyll based documentation in docs to the Starlight + Astro based documentation in docs-starlight. Make sure that the docs-starlight documentation is accurate and up-to-date with the docs documentation, and that any difference between them results in an improvement in the docs-starlight documentation.

Files:

  • docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md
🧠 Learnings (1)
📚 Learning: 2025-04-17T13:02:28.098Z
Learnt from: yhakbar
PR: gruntwork-io/terragrunt#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.

Applied to files:

  • docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-and-test
  • GitHub Check: Pull Request has non-contributor approval
🔇 Additional comments (2)
docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md (2)

68-70: Table header looks good; consider future-proofing with validation.

No blocking issues. I’m adding a verification script in a separate comment to prevent drift between this table and the CLI reference.


117-118: Verify flag name: --queue-include-units-reading.

This looks suspicious and may be a typo. Please confirm against the CLI help and flags docs; correct if needed.

Comment on lines 68 to 125
| Old Flag | New Flag |
|---------------------------------------------------|-----------------------------------------------------------|
| `--terragrunt-check` | `--check` |
| `--terragrunt-config` | `--config` |
| `--terragrunt-debug` | `--inputs-debug` |
| `--terragrunt-diff` | `--diff` |
| `--terragrunt-disable-bucket-update` | `--disable-bucket-update` |
| `--terragrunt-disable-command-validation` | `--disable-command-validation` |
| `--terragrunt-download-dir` | `--download-dir` |
| `--terragrunt-exclude-dir` | `--queue-exclude-dir` |
| `--terragrunt-excludes-file` | `--queue-excludes-file` |
| `--terragrunt-fail-on-state-bucket-creation` | removed (no equivalent; backend provisioning is explicit) |
| `--terragrunt-fetch-dependency-output-from-state` | `--dependency-fetch-output-from-state` |
| `--terragrunt-forward-tf-stdout` | `--tf-forward-stdout` |
| `--terragrunt-hclfmt-exclude-dir` | `--exclude-dir` |
| `--terragrunt-hclfmt-file` | `--file` |
| `--terragrunt-hclfmt-stdin` | `--stdin` |
| `--terragrunt-hclvalidate-json` | `--json` |
| `--terragrunt-hclvalidate-show-config-path` | `--show-config-path` |
| `--terragrunt-iam-assume-role-duration` | `--iam-assume-role-duration` |
| `--terragrunt-iam-role` | `--iam-assume-role` |
| `--terragrunt-iam-web-identity-token` | `--iam-assume-role-web-identity-token` |
| `--terragrunt-ignore-dependency-errors` | `--queue-ignore-errors` |
| `--terragrunt-ignore-dependency-order` | `--queue-ignore-dag-order` |
| `--terragrunt-ignore-external-dependencies` | `--queue-exclude-external` |
| `--terragrunt-include-dir` | `--queue-include-dir` |
| `--terragrunt-include-external-dependencies` | `--queue-include-external` |
| `--terragrunt-json-disable-dependent-modules` | `--disable-dependent-modules` |
| `--terragrunt-json-out-dir` | `--json-out-dir` |
| `--terragrunt-json-out` | `--out` |
| `--terragrunt-log-custom-format` | `--log-custom-format` |
| `--terragrunt-log-disable` | `--log-disable` |
| `--terragrunt-log-format` | `--log-format` |
| `--terragrunt-log-level` | `--log-level` |
| `--terragrunt-log-show-abs-paths` | `--log-show-abs-paths` |
| `--terragrunt-modules-that-include` | `--units-that-include` |
| `--terragrunt-no-auto-approve` | `--no-auto-approve` |
| `--terragrunt-no-auto-init` | `--no-auto-init` |
| `--terragrunt-no-auto-retry` | `--no-auto-retry` |
| `--terragrunt-no-color` | `--no-color` |
| `--terragrunt-no-destroy-dependencies-check` | `--no-destroy-dependencies-check` |
| `--terragrunt-out-dir` | `--out-dir` |
| `--terragrunt-parallelism` | `--parallelism` |
| `--terragrunt-provider-cache-dir` | `--provider-cache-dir` |
| `--terragrunt-provider-cache-hostname` | `--provider-cache-hostname` |
| `--terragrunt-provider-cache-port` | `--provider-cache-port` |
| `--terragrunt-provider-cache-registry-names` | `--provider-cache-registry-names` |
| `--terragrunt-provider-cache-token` | `--provider-cache-token` |
| `--terragrunt-provider-cache` | `--provider-cache` |
| `--terragrunt-queue-include-units-reading` | `--queue-include-units-reading` |
| `--terragrunt-source-map` | `--source-map` |
| `--terragrunt-source-update` | `--source-update` |
| `--terragrunt-source` | `--source` |
| `--terragrunt-strict-include` | `--queue-strict-include` |
| `--terragrunt-strict-validate` | `--strict-validate` |
| `--terragrunt-use-partial-parse-config-cache` | `--use-partial-parse-config-cache` |
| `--terragrunt-working-dir` | `--working-dir` |

Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Automate verification to prevent table/CLI drift.

Run this to (a) ensure every “New Flag” appears somewhere in docs-starlight, and (b) catch the missing --terragrunt-non-interactive row.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md"

echo "Checking that --terragrunt-non-interactive is present in the migration table..."
if ! rg -n --fixed-strings '| `--terragrunt-non-interactive`' "$FILE" >/dev/null; then
  echo "MISSING ROW: --terragrunt-non-interactive -> --non-interactive"
fi

echo "Extracting 'New Flag' column from the migration table..."
# Grab the table block lines, then column 3 (New Flag), strip code fences and whitespace.
mapfile -t NEW_FLAGS < <(awk '
  $0 ~ /^\|/ {print $0}
' "$FILE" \
| awk -F"|" '{gsub(/`/,"",$3); gsub(/^[ \t]+|[ \t]+$/,"",$3); if ($3 != "" && $3 !~ /^removed/) print $3 }' \
| sort -u)

echo "Found ${#NEW_FLAGS[@]} new flags."

missing=0
for flag in "${NEW_FLAGS[@]}"; do
  # Only search docs for the literal flag string
  if ! rg -n --fixed-strings --glob 'docs-starlight/**' "$flag" >/dev/null; then
    echo "MISSING DOCS REFERENCE: $flag"
    ((missing++)) || true
  fi
done

echo "Verifying suspicious or easily mistyped flags..."
for flag in "--queue-excludes-file" "--queue-include-units-reading"; do
  if rg -n --fixed-strings "$flag" "$FILE" >/dev/null; then
    if ! rg -n --fixed-strings --glob 'docs-starlight/**' "$flag" >/dev/null; then
      echo "POTENTIAL TYPO (not referenced elsewhere): $flag"
    fi
  fi
done

if [ "$missing" -eq 0 ]; then
  echo "All new flags are referenced somewhere in docs-starlight."
else
  echo "$missing flags are not referenced in docs-starlight."
fi

Length of output: 992


Add missing CLI flag mapping and fix verification script

The migration table in docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md is missing this row:

| `--terragrunt-non-interactive` | `--non-interactive` |

Also the automation script fails on mapfile (no /dev/fd); replace it with a POSIX-compatible capture, for example:

NEW_FLAGS=$(awk '
  /^\|/ { gsub(/`/,"",$3); gsub(/^[[:space:]]+|[[:space:]]+$/,"",$3);
           if ($3 != "" && $3 !~ /^removed/) print $3 }
' "$FILE" | sort -u)

for flag in $NEW_FLAGS; do# existing check logic
done

This ensures both the new flag is documented and the check runs reliably.

🤖 Prompt for AI Agents
In docs-starlight/src/content/docs/07-migrate/03-cli-redesign.md around lines 68
to 125, add the missing CLI flag mapping row exactly: `|
--terragrunt-non-interactive | --non-interactive |` into the migration table,
and update the verification automation to avoid mapfile and /dev/fd by replacing
the mapfile capture with a POSIX-compatible pipeline that extracts the "New
Flag" column (strip backticks and whitespace, ignore empty/removed entries)
using awk (or similar) piped to sort -u, then iterate over the resulting words
with a simple for loop to run the existing check logic.

SkipDependenciesInputs = "skip-dependencies-inputs"

// RequireExplicitBootstrap is the control that prevents the backend for remote state from being bootstrapped unless the `--backend-bootstrap` flag is specified.
RequireExplicitBootstrap = "require-explicit-bootstrap"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't remove strict controls, we should only complete them. That prevents the breaking change of users using --strict-control require-explicit-bootstrap. They'll just get a warning instead this way.

yhakbar
yhakbar previously approved these changes Sep 5, 2025
@denis256 denis256 enabled auto-merge (squash) September 5, 2025 17:02
@yhakbar yhakbar disabled auto-merge September 5, 2025 17:06
@yhakbar yhakbar merged commit 8703c3b into main Sep 5, 2025
120 of 123 checks passed
@yhakbar yhakbar deleted the feature-4598 branch September 5, 2025 17:06
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 backend provisioning as default behavior

7 participants