Repository: gruntwork-io/terragrunt

Issue:
Inconsistent behavior of get_terragrunt_dir() in terragrunt.stack.hcl
## Describe the bug

when excecuting " terragrunt stack generate ; terragrunt apply --all" in the root of the live repo and using get_terragrunt_dir() in a terragrunt.stack.hcl file, this fuctions always returns "." instead of the directory where the terragrunt.stack.hcl file is located

observerd output
```
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: Outputs:
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: 
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: terragrunt_dir = "."
```

expected output
```
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: Outputs:
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: 
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: terragrunt_dir = "./tennant_1"
```


## Steps To Reproduce

Setup the directory strucutre as discribed below
```
cd live
terragrunt stack generate ; terragrunt apply --all
```

```
.
├── live
│   ├── root.hcl
│   └── tennant_1
│       └── terragrunt.stack.hcl
└── unit_a
    ├── main.tf
    └── terragrunt.hcl
````

### File: ./unit_a/terragrunt.hcl
```plaintext
include "root" {
  path = find_in_parent_folders("root.hcl")
}

terraform {
  source = "."
}

inputs = {
  terragrunt_dir = values.terragrunt_dir
}

```

### File: ./unit_a/main.tf
```plaintext
variable "terragrunt_dir" {}

output "terragrunt_dir" {
  value = var.terragrunt_dir
}
```

### File: ./live/tennant_1/terragrunt.stack.hcl
```plaintext
unit "unit_a" {
  source = "../../unit_a"
  path   = "unit_a"
  values = {
    terragrunt_dir = get_terragrunt_dir()
  }
}
```

### File: ./live/root.hcl
```plaintext
```

## Expected behavior

```
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: Outputs:
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: 
13:59:45.536 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: terragrunt_dir = "./tennant_1"
```

## Nice to haves


## Versions

```
❯ terragrunt -version
terragrunt version v0.78.0

❯ terraform -version
Terraform v1.5.3
on linux_amd64
```





Hints from issue comments:
@mark854542: i think all drectory fuctions return "."
How can I determin where I am in the path structure so i can infer the tennant form the path ?

```
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: get_original_terragrunt_dir = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: get_parent_terragrunt_dir = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: get_path_from_repo_root = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: get_path_to_repo_root = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: get_repo_root = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: get_terragrunt_dir = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: path_relative_from_include = "."
14:45:36.172 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform: path_relative_to_include = "."
```` @denis256: Just to clarify: `get_terragrunt_dir()` is not documented to return the path of the `terragrunt.stack.hcl` file. It returns the directory of the `terragrunt.hcl `file where it's being evaluated.


https://terragrunt.gruntwork.io/docs/reference/built-in-functions/#get_terragrunt_dir

@mark854542: agreed but by extrapolation i woud assume that if it is used in a terragrunt.stack.hcl it would return its path or an error message that it can not be used
@mark854542: I noticed some other stange behavior

If a create the following unit

```
unit "unit_a" {
  source = "../../unit_a"
  path   = "unit_a"
  values = {
    output4 = regexall("([^/]+)", get_terragrunt_dir())
    outputs = {
      output1 = get_terragrunt_dir()
      output2 = "${get_terragrunt_dir()}"
      output3 = "/${get_terragrunt_dir()}"
      output5 = ".${get_terragrunt_dir()}"
    }
  }
}
```

and pass it all down the terraform module
````
inputs = {
  outputs = values.outputs
  output4 = values.output4
}
````

I get the following output

```
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform: Outputs:
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform: output4 = "[[\"live\"],[\"tennant_1\"]]"
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform: outputs = tomap({
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform:   "output1" = "."
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform:   "output2" = "."
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform:   "output3" = "//live/tennant_1"
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform:   "output5" = ".."
21:54:24.353 STDOUT [.terragrunt-stack/unit_a] terraform: })
```

The difference betweem `"/${get_terragrunt_dir()}"` displaying the full path and `"${get_terragrunt_dir()}"` displaying a period is especialy odd

Is this intended and documented behavior
Can I rely on this to keep on working in the future ?



@mark854542: I found out this is intended 
If I use `terragrunt run apply --all --log-show-abs-paths`
all outputs contain the full path @denis256: Hi,
can also be used `abspath()` to get absolute path, if used in HCL

Reference: https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/file/abspath@yhakbar: Fix released in [v0.82.2](https://github.com/gruntwork-io/terragrunt/releases/tag/v0.82.2)@mark854542: @james03160927 

It works

07:56:26.132 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform:   ~ outputs = {
07:56:26.132 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform:       ~ output1 = "." -> "./tennant_1"
07:56:26.132 STDOUT [tennant_1/.terragrunt-stack/unit_a] terraform:       ~ output2 = "." -> "./tennant_1"


Thank you james and the rest of the team

Solution patch:
diff --git a/cli/commands/hcl/validate/validate.go b/cli/commands/hcl/validate/validate.go
index 4b446428..2aba7c83 100644
--- a/cli/commands/hcl/validate/validate.go
+++ b/cli/commands/hcl/validate/validate.go
@@ -101,6 +101,14 @@ func RunValidate(ctx context.Context, l log.Logger, opts *options.TerragruntOpti
 		if err := writeDiagnostics(l, opts, diags); err != nil {
 			return err
 		}
+
+		// If there were diagnostics and stackErr is currently nil,
+		// create a new error to signal overall validation failure.
+		//
+		// This also ensures a non-zero exit code is returned by Terragrunt.
+		if stackErr == nil {
+			stackErr = errors.Errorf("%d HCL validation error(s) found", len(diags))
+		}
 	}
 
 	return stackErr
@@ -276,8 +284,8 @@ func getTerraformInputNamesFromEnvVar(opts *options.TerragruntOptions, terragrun
 	)
 
 	for envName := range envVars {
-		if strings.HasPrefix(envName, tfVarPrefix) {
-			inputName := strings.TrimPrefix(envName, tfVarPrefix)
+		if after, ok := strings.CutPrefix(envName, tfVarPrefix); ok {
+			inputName := after
 			out = append(out, inputName)
 		}
 	}
@@ -450,8 +458,8 @@ func GetVarFlagsFromArgList(argList []string) ([]string, []string, error) {
 			vars = append(vars, splitArg[1])
 		}
 
-		if strings.HasPrefix(shlexedArg, "-var-file=") {
-			varFiles = append(varFiles, strings.TrimPrefix(shlexedArg, "-var-file="))
+		if after, ok := strings.CutPrefix(shlexedArg, "-var-file="); ok {
+			varFiles = append(varFiles, after)
 		}
 	}
 
diff --git a/config/config_helpers.go b/config/config_helpers.go
index 5b148233..1270b5ef 100644
--- a/config/config_helpers.go
+++ b/config/config_helpers.go
@@ -271,7 +271,12 @@ func getPathToRepoRoot(ctx *ParsingContext, l log.Logger) (string, error) {
 
 // GetTerragruntDir returns the directory where the Terragrunt configuration file lives.
 func GetTerragruntDir(ctx *ParsingContext, l log.Logger) (string, error) {
-	terragruntConfigFileAbsPath, err := filepath.Abs(ctx.TerragruntOptions.TerragruntConfigPath)
+	path := ctx.TerragruntOptions.TerragruntConfigPath
+	if val, ok := ctx.Context.Value(stackParserContext{}).(stackParserContext); ok {
+		path = val.stackConfigFile
+	}
+
+	terragruntConfigFileAbsPath, err := filepath.Abs(path)
 	if err != nil {
 		return "", errors.New(err)
 	}
diff --git a/config/dependency.go b/config/dependency.go
index 7f03b883..c841efa3 100644
--- a/config/dependency.go
+++ b/config/dependency.go
@@ -414,8 +414,6 @@ func dependencyBlocksToCtyValue(ctx *ParsingContext, l log.Logger, dependencyCon
 	dependencyErrGroup, _ := errgroup.WithContext(ctx)
 
 	for _, dependencyConfig := range dependencyConfigs {
-		dependencyConfig := dependencyConfig // https://golang.org/doc/faq#closures_and_goroutines
-
 		dependencyErrGroup.Go(func() error {
 			// Loose struct to hold the attributes of the dependency. This includes:
 			// - outputs: The module outputs of the target config
diff --git a/config/stack.go b/config/stack.go
index 43387c82..9d8962ff 100644
--- a/config/stack.go
+++ b/config/stack.go
@@ -72,6 +72,10 @@ type Stack struct {
 	Path         string     `hcl:"path,attr"`
 }
 
+type stackParserContext struct {
+	stackConfigFile string
+}
+
 // GenerateStacks generates the stack files.
 func GenerateStacks(ctx context.Context, l log.Logger, opts *options.TerragruntOptions) error {
 	processedFiles := make(map[string]bool)
@@ -687,6 +691,7 @@ func (u *Unit) ReadOutputs(ctx context.Context, l log.Logger, opts *options.Terr
 func ReadStackConfigFile(ctx context.Context, l log.Logger, opts *options.TerragruntOptions, filePath string, values *cty.Value) (*StackConfig, error) {
 	l.Debugf("Reading Terragrunt stack config file at %s", filePath)
 
+	ctx = context.WithValue(ctx, stackParserContext{}, stackParserContext{stackConfigFile: filePath})
 	parser := NewParsingContext(ctx, l, opts)
 
 	file, err := hclparse.NewParser(parser.ParserOptions...).ParseFromFile(filePath)
diff --git a/docs-starlight/src/components/Flag.astro b/docs-starlight/src/components/Flag.astro
index 17e229f7..63c28f39 100644
--- a/docs-starlight/src/components/Flag.astro
+++ b/docs-starlight/src/components/Flag.astro
@@ -11,7 +11,7 @@ const { slug } = Astro.props;
 
 const flagEntry = await getEntry('flags', slug) as CollectionEntry<'flags'>;
 const { Content } = await render(flagEntry);
-const { aliases, description, type, env, name } = flagEntry.data;
+const { aliases, description, type, env, name, defaultVal } = flagEntry.data;
 ---
 
 <section id={name}>
@@ -21,6 +21,11 @@ const { aliases, description, type, env, name } = flagEntry.data;
     <div>
       <span>Type: </span><Badge text={type} variant="note" style={{ fontWeight: 'bold' }}/>
     </div>
+    {defaultVal && (
+      <div>
+        <span>Default: </span><Badge text={defaultVal} variant="tip" style={{ fontWeight: 'bold' }}/>
+      </div>
+    )}
     {aliases && aliases.length > 0 && (
       <>
         <p>Aliases:</p>
diff --git a/docs-starlight/src/content.config.ts b/docs-starlight/src/content.config.ts
index 50f42c2a..3ae96e22 100644
--- a/docs-starlight/src/content.config.ts
+++ b/docs-starlight/src/content.config.ts
@@ -52,6 +52,7 @@ const flags = defineCollection({
 	schema: z.object({
 		name: z.string(),
 		description: z.string(),
+		defaultVal: z.string().optional(),
 		type: z.string(),
 		env: z.array(z.string()).optional(),
 		aliases: z.array(z.string()).optional(),
diff --git a/docs-starlight/src/data/flags/queue-excludes-file.mdx b/docs-starlight/src/data/flags/queue-excludes-file.mdx
index 744116e8..f9907d51 100644
--- a/docs-starlight/src/data/flags/queue-excludes-file.mdx
+++ b/docs-starlight/src/data/flags/queue-excludes-file.mdx
@@ -1,11 +1,17 @@
 ---
 name: queue-excludes-file
-description: Path to a file containing Unix-style globs of directories to exclude from the queue of Units to run.
+description: Path to a file with a list of directories that need to be excluded when running `run --all` commands.
 type: string
+defaultVal: .terragrunt-excludes
 env:
   - TG_QUEUE_EXCLUDES_FILE
 ---
 
-Specifies a file containing patterns of directories to exclude when running commands with [`--all`](/docs/reference/cli/commands/run#all).
+Units in these directories will be excluded during execution of the commands. If a relative path is specified, it should be relative from
+[--working-dir](/docs/reference/cli/global-flags#working-directory). This will only exclude the module, not its dependencies.
 
-To learn more about how to use this flag, see the [Stacks](/docs/features/stacks/#the-run---all-command) feature documentation.
+This flag has been designed to integrate nicely with the `hcl validate` command, which can return a list of invalid files delimited by newlines when passed the `--show-config-path` flag. To integrate the two, you can run something like the following using bash process substitution:
+
+```bash
+terragrunt run --all plan --queue-excludes-file <(terragrunt hcl validate --show-config-path || true)
+```
diff --git a/docs/_docs/04_reference/02-cli-options.md b/docs/_docs/04_reference/02-cli-options.md
index 05dad011..5823e9a5 100644
--- a/docs/_docs/04_reference/02-cli-options.md
+++ b/docs/_docs/04_reference/02-cli-options.md
@@ -1783,14 +1783,14 @@ When passed in, the `*-all` commands continue processing components even if a de
 **Environment Variable Alias**: `TERRAGRUNT_EXCLUDES_FILE` (deprecated: [See migration guide](/docs/migrate/cli-redesign/))<br/>
 **Requires an argument**: `--queue-excludes-file /path/to/file`<br/>
 
-Path to a file with a list of directories that need to be excluded when running *-all commands, by default `.terragrunt-excludes`. Modules under these directories will be
+Path to a file with a list of directories that need to be excluded when running `run --all` commands, by default `.terragrunt-excludes`. Units in these directories will be
 excluded during execution of the commands. If a relative path is specified, it should be relative from
 [--working-dir](#working-dir). This will only exclude the module, not its dependencies.
 
-This flag has been designed to integrate nicely with the `hclvalidate` command, which can return a list of invalid files delimited by newlines when passed the `--show-config-path` flag. To integrate the two, you can run something like the following using bash process substitution:
+This flag has been designed to integrate nicely with the `hcl validate` command, which can return a list of invalid files delimited by newlines when passed the `--show-config-path` flag. To integrate the two, you can run something like the following using bash process substitution:
 
 ```bash
-terragrunt run --all plan --queue-excludes-file <(terragrunt hclvalidate --show-config-path)
+terragrunt run --all plan --queue-excludes-file <(terragrunt hcl validate --show-config-path || true)
 ```
 
 ### queue-exclude-dir
diff --git a/internal/cas/content.go b/internal/cas/content.go
index 64a28cf9..08132d4a 100644
--- a/internal/cas/content.go
+++ b/internal/cas/content.go
@@ -109,82 +109,7 @@ func (c *Content) Store(l log.Logger, hash string, data []byte) error {
 		return wrapError("create_partition_dir", partitionDir, ErrCreateDir)
 	}
 
-	path := c.getPath(hash)
-	tempPath := path + ".tmp"
-
-	f, err := os.OpenFile(tempPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, RegularFilePerms)
-	if err != nil {
-		return wrapError("create_temp_file", tempPath, err)
-	}
-
-	buf := bufio.NewWriter(f)
-
-	if _, err := buf.Write(data); err != nil {
-		f.Close()
-
-		if removeErr := os.Remove(tempPath); removeErr != nil {
-			l.Warnf("failed to remove temp file %s: %v", tempPath, removeErr)
-		}
-
-		return wrapError("write_to_store", tempPath, err)
-	}
-
-	if err := buf.Flush(); err != nil {
-		f.Close()
-
-		if removeErr := os.Remove(tempPath); removeErr != nil {
-			l.Warnf("failed to remove temp file %s: %v", tempPath, removeErr)
-		}
-
-		return wrapError("flush_buffer", tempPath, err)
-	}
-
-	if err := f.Close(); err != nil {
-		if removeErr := os.Remove(tempPath); removeErr != nil {
-			l.Warnf("failed to remove temp file %s: %v", tempPath, removeErr)
-		}
-
-		return wrapError("close_file", tempPath, err)
-	}
-
-	// Set read-only permissions on the temporary file
-	if err := os.Chmod(tempPath, StoredFilePerms); err != nil {
-		if removeErr := os.Remove(tempPath); removeErr != nil {
-			l.Warnf("failed to remove temp file %s: %v", tempPath, removeErr)
-		}
-
-		return wrapError("chmod_temp_file", tempPath, err)
-	}
-
-	// For Windows, handle readonly attributes specifically
-	if runtime.GOOS == WindowsOS {
-		// Check if a destination file exists and is read-only
-		if _, err := os.Stat(path); err == nil {
-			// File exists, make it writable before rename operation
-			if err := os.Chmod(path, RegularFilePerms); err != nil {
-				l.Warnf("failed to make destination file writable %s: %v", path, err)
-			}
-		}
-	}
-
-	// Atomic rename
-	if err := os.Rename(tempPath, path); err != nil {
-		if removeErr := os.Remove(tempPath); removeErr != nil {
-			l.Warnf("failed to remove temp file %s: %v", tempPath, removeErr)
-		}
-
-		return wrapError("finalize_store", path, err)
-	}
-
-	// For Windows, we need to set the permissions again after rename
-	if runtime.GOOS == WindowsOS {
-		// Ensure the file has read-only permissions after rename
-		if err := os.Chmod(path, StoredFilePerms); err != nil {
-			return wrapError("chmod_final_file", path, err)
-		}
-	}
-
-	return nil
+	return c.writeContentToFile(l, hash, data)
 }
 
 // Ensure ensures that a content item exists in the store
@@ -227,6 +152,12 @@ func (c *Content) EnsureWithWait(l log.Logger, hash string, data []byte) error {
 		return wrapError("create_partition_dir", partitionDir, ErrCreateDir)
 	}
 
+	return c.writeContentToFile(l, hash, data)
+}
+
+// writeContentToFile writes data to a temporary file,
+// sets appropriate permissions, and performs an atomic rename.
+func (c *Content) writeContentToFile(l log.Logger, hash string, data []byte) error {
 	path := c.getPath(hash)
 	tempPath := path + ".tmp"
 
diff --git a/internal/cas/getter.go b/internal/cas/getter.go
index 48222b73..b4024e87 100644
--- a/internal/cas/getter.go
+++ b/internal/cas/getter.go
@@ -30,8 +30,6 @@ func NewCASGetter(l log.Logger, cas *CAS, opts *CloneOptions) *CASGetter {
 			new(getter.GitDetector),
 			new(getter.BitBucketDetector),
 			new(getter.GitLabDetector),
-			// This always has to be the last detector,
-			// as we check for the last detector in Detect().
 			new(getter.FileDetector),
 		},
 		CAS:    cas,
@@ -93,15 +91,15 @@ func (g *CASGetter) Detect(req *getter.Request) (bool, error) {
 		return true, nil
 	}
 
-	for i, detector := range g.Detectors {
+	for _, detector := range g.Detectors {
 		src, ok, err := detector.Detect(req.Src, req.Pwd)
 		if err != nil {
 			return ok, err
 		}
 
 		if ok {
-			// The final detector is always the FileDetector.
-			if i == len(g.Detectors)-1 {
+			// Check if this is a FileDetector using type assertion
+			if _, isFileDetector := detector.(*getter.FileDetector); isFileDetector {
 				info, statErr := os.Stat(src)
 				if statErr != nil {
 					return false, fmt.Errorf("%w: %s", ErrDirectoryNotFound, src)
diff --git a/internal/cas/tree.go b/internal/cas/tree.go
index 1a35f86c..597c15ca 100644
--- a/internal/cas/tree.go
+++ b/internal/cas/tree.go
@@ -7,7 +7,8 @@ import (
 	"path/filepath"
 	"runtime"
 	"strings"
-	"sync"
+
+	"golang.org/x/sync/errgroup"
 )
 
 const (
@@ -149,91 +150,44 @@ func (t *Tree) LinkTree(ctx context.Context, store *Store, targetDir string) err
 		}
 	}
 
+	// Use errgroup for concurrent processing
+	g, ctx := errgroup.WithContext(ctx)
+
+	// Set concurrency limit
 	scalingFactor := 2
 	maxWorkers := max(1, runtime.NumCPU()/scalingFactor)
-	workChan := make(chan workItem, len(workItems))
-	errChan := make(chan error, 1)
-
-	var wg sync.WaitGroup
-
-	for i := 0; i < maxWorkers; i++ {
-		wg.Add(1)
-
-		go func() {
-			defer wg.Done()
+	g.SetLimit(maxWorkers)
 
-			for work := range workChan {
-				select {
-				case <-ctx.Done():
-					return
-				case <-errChan:
-					return
-				default:
+	// Process work items concurrently
+	for _, work := range workItems {
+		g.Go(func() error {
+			switch work.itemType {
+			case "link":
+				err := content.Link(ctx, work.entry.Hash, work.path)
+				if err != nil {
+					return wrapError("link_blob", work.path, err)
 				}
-
-				var err error
-
-				switch work.itemType {
-				case "link":
-					err = content.Link(ctx, work.entry.Hash, work.path)
-					if err != nil {
-						err = wrapError("link_blob", work.path, err)
-					}
-				case "subtree":
-					var treeData []byte
-
-					treeData, err = content.Read(work.entry.Hash)
-					if err != nil {
-						err = wrapError("read_tree", work.entry.Hash, err)
-						break
-					}
-
-					var subTree *Tree
-
-					subTree, err = ParseTree(string(treeData), work.path)
-					if err != nil {
-						err = wrapError("parse_tree", work.entry.Hash, err)
-						break
-					}
-
-					err = subTree.LinkTree(ctx, store, work.path)
-					if err != nil {
-						err = wrapError("link_subtree", work.path, err)
-					}
+			case "subtree":
+				treeData, err := content.Read(work.entry.Hash)
+				if err != nil {
+					return wrapError("read_tree", work.entry.Hash, err)
 				}
 
+				subTree, err := ParseTree(string(treeData), work.path)
 				if err != nil {
-					select {
-					case errChan <- err:
-					default:
-					}
+					return wrapError("parse_tree", work.entry.Hash, err)
+				}
 
-					return
+				err = subTree.LinkTree(ctx, store, work.path)
+				if err != nil {
+					return wrapError("link_subtree", work.path, err)
 				}
 			}
-		}()
-	}
 
-	for _, work := range workItems {
-		select {
-		case <-ctx.Done():
-			close(workChan)
-			return ctx.Err()
-		case err := <-errChan:
-			close(workChan)
-			return err
-		case workChan <- work:
-		}
+			return nil
+		})
 	}
 
-	close(workChan)
-
-	wg.Wait()
-
-	select {
-	case err := <-errChan:
-		return err
-	default:
-		return nil
-	}
+	// Wait for all goroutines to complete and return first error if any
+	return g.Wait()
 }
diff --git a/tf/cache/server.go b/tf/cache/server.go
index 699a5e27..4c89d677 100644
--- a/tf/cache/server.go
+++ b/tf/cache/server.go
@@ -92,8 +92,6 @@ func (server *Server) Run(ctx context.Context, ln net.Listener) error {
 	errGroup, ctx := errgroup.WithContext(ctx)
 
 	for _, service := range server.services {
-		service := service
-
 		errGroup.Go(func() error {
 			return service.Run(ctx)
 		})
diff --git a/tflint/tflint.go b/tflint/tflint.go
index 4f20610b..d1cc06ee 100644
--- a/tflint/tflint.go
+++ b/tflint/tflint.go
@@ -182,8 +182,8 @@ func tfArgumentsToTflintVar(l log.Logger, hook config.Hook,
 		if arg.EnvVars != nil {
 			// extract env_vars
 			for name, value := range *arg.EnvVars {
-				if strings.HasPrefix(name, tfVarPrefix) {
-					varName := strings.TrimPrefix(name, tfVarPrefix)
+				if after, ok := strings.CutPrefix(name, tfVarPrefix); ok {
+					varName := after
 
 					varValue, err := util.AsTerraformEnvVarJSONValue(value)
 					if err != nil {
@@ -199,14 +199,14 @@ func tfArgumentsToTflintVar(l log.Logger, hook config.Hook,
 		if arg.Arguments != nil {
 			// extract variables and var files from arguments
 			for _, value := range *arg.Arguments {
-				if strings.HasPrefix(value, argVarPrefix) {
-					varName := strings.TrimPrefix(value, argVarPrefix)
+				if after, ok := strings.CutPrefix(value, argVarPrefix); ok {
+					varName := after
 					newVar := fmt.Sprintf("--var='%s'", varName)
 					variables = append(variables, newVar)
 				}
 
-				if strings.HasPrefix(value, argVarFilePrefix) {
-					varName := strings.TrimPrefix(value, argVarFilePrefix)
+				if after, ok := strings.CutPrefix(value, argVarFilePrefix); ok {
+					varName := after
 					newVar := "--var-file=" + varName
 					variables = append(variables, newVar)
 				}



Test patch:
diff --git a/cli/commands/catalog/tui/model_test.go b/cli/commands/catalog/tui/model_test.go
index c9eb42f0..2bc68c1b 100644
--- a/cli/commands/catalog/tui/model_test.go
+++ b/cli/commands/catalog/tui/model_test.go
@@ -41,7 +41,7 @@ func createMockCatalogService(t *testing.T, opts *options.TerragruntOptions) cat
 		// Initialize git repository
 		gitDir := filepath.Join(dummyRepoDir, ".git")
 		os.MkdirAll(gitDir, 0755)
-		os.WriteFile(filepath.Join(gitDir, "config"), []byte(fmt.Sprintf(`[core]
+		os.WriteFile(filepath.Join(gitDir, "config"), fmt.Appendf(nil, `[core]
 	repositoryformatversion = 0
 	filemode = true
 	bare = false
@@ -52,7 +52,7 @@ func createMockCatalogService(t *testing.T, opts *options.TerragruntOptions) cat
 [branch "main"]
 	remote = origin
 	merge = refs/heads/main
-`, repoURL)), 0644)
+`, repoURL), 0644)
 		os.WriteFile(filepath.Join(gitDir, "HEAD"), []byte("ref: refs/heads/main\n"), 0644)
 
 		// Create refs directory structure
diff --git a/cli/commands/hcl/format/format_test.go b/cli/commands/hcl/format/format_test.go
index f3157b48..50d0ddbf 100644
--- a/cli/commands/hcl/format/format_test.go
+++ b/cli/commands/hcl/format/format_test.go
@@ -50,7 +50,6 @@ func TestHCLFmt(t *testing.T) {
 		}
 		for _, dir := range dirs {
 			// Capture range variable into for block so it doesn't change while looping
-			dir := dir
 
 			t.Run(dir, func(t *testing.T) {
 				t.Parallel()
@@ -114,7 +113,6 @@ func TestHCLFmtErrors(t *testing.T) {
 	}
 	for _, dir := range dirs {
 		// Capture range variable into for block so it doesn't change while looping
-		dir := dir
 
 		t.Run(dir, func(t *testing.T) {
 			t.Parallel()
@@ -164,7 +162,6 @@ func TestHCLFmtCheck(t *testing.T) {
 
 	for _, dir := range dirs {
 		// Capture range variable into for block so it doesn't change while looping
-		dir := dir
 
 		t.Run(dir, func(t *testing.T) {
 			t.Parallel()
@@ -210,7 +207,6 @@ func TestHCLFmtCheckErrors(t *testing.T) {
 
 	for _, dir := range dirs {
 		// Capture range variable into for block so it doesn't change while looping
-		dir := dir
 
 		t.Run(dir, func(t *testing.T) {
 			t.Parallel()
@@ -268,7 +264,6 @@ func TestHCLFmtFile(t *testing.T) {
 	// test that none of the other files were formatted
 	for _, dir := range dirs {
 		// Capture range variable into for block so it doesn't change while looping
-		dir := dir
 
 		t.Run(dir, func(t *testing.T) {
 			t.Parallel()
diff --git a/cli/commands/run/cli_test.go b/cli/commands/run/cli_test.go
index 45c2eca3..58790acf 100644
--- a/cli/commands/run/cli_test.go
+++ b/cli/commands/run/cli_test.go
@@ -37,7 +37,6 @@ func TestAction(t *testing.T) {
 	}
 
 	for _, tc := range tt {
-		tc := tc
 
 		t.Run(tc.name, func(t *testing.T) {
 			t.Parallel()
diff --git a/config/config_helpers_test.go b/config/config_helpers_test.go
index 5e56135f..6a4c9f2b 100644
--- a/config/config_helpers_test.go
+++ b/config/config_helpers_test.go
@@ -202,7 +202,6 @@ func TestRunCommand(t *testing.T) {
 		},
 	}
 	for _, tc := range testCases {
-		tc := tc
 
 		t.Run(tc.terragruntOptions.TerragruntConfigPath, func(t *testing.T) {
 			t.Parallel()
@@ -315,7 +314,6 @@ func TestFindInParentFolders(t *testing.T) {
 	}
 
 	for _, tc := range testCases {
-		tc := tc
 
 		t.Run(tc.name, func(t *testing.T) {
 			t.Parallel()
@@ -385,7 +383,6 @@ func TestResolveTerragruntInterpolation(t *testing.T) {
 	for _, tc := range testCases {
 		// The following is necessary to make sure tc's values don't
 		// get updated due to concurrency within the scope of t.Run(..) below
-		tc := tc
 
 		t.Run(fmt.Sprintf("%s--%s", tc.str, tc.terragruntOptions.TerragruntConfigPath), func(t *testing.T) {
 			t.Parallel()
@@ -485,7 +482,6 @@ func TestResolveEnvInterpolationConfigString(t *testing.T) {
 	for _, tc := range testCases {
 		// The following is necessary to make sure tc's values don't
 		// get updated due to concurrency within the scope of t.Run(..) below
-		tc := tc
 		t.Run(tc.str, func(t *testing.T) {
 			t.Parallel()
 
@@ -535,7 +531,6 @@ func TestResolveCommandsInterpolationConfigString(t *testing.T) {
 	for _, tc := range testCases {
 		// The following is necessary to make sure tc's values don't
 		// get updated due to concurrency within the scope of t.Run(..) below
-		tc := tc
 
 		t.Run(tc.str, func(t *testing.T) {
 			t.Parallel()
@@ -796,7 +791,6 @@ func TestTerraformBuiltInFunctions(t *testing.T) {
 	}
 
 	for _, tc := range testCases {
-		tc := tc
 
 		t.Run(tc.input, func(t *testing.T) {
 			t.Parallel()
diff --git a/internal/report/report_test.go b/internal/report/report_test.go
index ca3c24c3..110e28f6 100644
--- a/internal/report/report_test.go
+++ b/internal/report/report_test.go
@@ -674,7 +674,7 @@ func TestWriteJSON(t *testing.T) {
 			require.NoError(t, err)
 
 			// Parse both expected and actual JSON to compare them
-			var expectedJSON, actualJSON []map[string]interface{}
+			var expectedJSON, actualJSON []map[string]any
 			err = json.Unmarshal([]byte(tt.expected), &expectedJSON)
 			require.NoError(t, err)
 			err = json.Unmarshal(actualBytes, &actualJSON)
@@ -795,7 +795,7 @@ func TestWriteSchema(t *testing.T) {
 	assert.JSONEq(t, ExpectedSchema, buf.String())
 
 	// Parse the schema
-	var schema map[string]interface{}
+	var schema map[string]any
 	err = json.Unmarshal(buf.Bytes(), &schema)
 	require.NoError(t, err)
 
@@ -805,15 +805,15 @@ func TestWriteSchema(t *testing.T) {
 	assert.Equal(t, "Terragrunt Run Report Schema", schema["title"])
 
 	// Verify the items schema
-	items, ok := schema["items"].(map[string]interface{})
+	items, ok := schema["items"].(map[string]any)
 	require.True(t, ok)
 
 	// Verify the properties
-	properties, ok := items["properties"].(map[string]interface{})
+	properties, ok := items["properties"].(map[string]any)
 	require.True(t, ok)
 
 	// Verify required fields
-	required, ok := items["required"].([]interface{})
+	required, ok := items["required"].([]any)
 	require.True(t, ok)
 	assert.Contains(t, required, "Name")
 	assert.Contains(t, required, "Started")
@@ -821,17 +821,17 @@ func TestWriteSchema(t *testing.T) {
 	assert.Contains(t, required, "Result")
 
 	// Verify field types
-	assert.Equal(t, "string", properties["Name"].(map[string]interface{})["type"])
-	assert.Equal(t, "string", properties["Result"].(map[string]interface{})["type"])
-	assert.Equal(t, "string", properties["Started"].(map[string]interface{})["type"])
-	assert.Equal(t, "string", properties["Ended"].(map[string]interface{})["type"])
+	assert.Equal(t, "string", properties["Name"].(map[string]any)["type"])
+	assert.Equal(t, "string", properties["Result"].(map[string]any)["type"])
+	assert.Equal(t, "string", properties["Started"].(map[string]any)["type"])
+	assert.Equal(t, "string", properties["Ended"].(map[string]any)["type"])
 
 	// Verify optional fields
-	reason, ok := properties["Reason"].(map[string]interface{})
+	reason, ok := properties["Reason"].(map[string]any)
 	require.True(t, ok)
 	assert.Equal(t, "string", reason["type"])
 
-	cause, ok := properties["Cause"].(map[string]interface{})
+	cause, ok := properties["Cause"].(map[string]any)
 	require.True(t, ok)
 	assert.Equal(t, "string", cause["type"])
 }
diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go
index 23d02c63..96a0cc7c 100644
--- a/internal/worker/worker_test.go
+++ b/internal/worker/worker_test.go
@@ -68,7 +68,6 @@ func TestSomeTasksReturnErrors(t *testing.T) {
 
 	// Submit tasks, half of which return an error
 	for i := range 10 {
-		i := i
 		wp.Submit(func() error {
 			if i%2 == 0 {
 				return errors.New("mock error")
diff --git a/shell/error_explainer_test.go b/shell/error_explainer_test.go
index 6025eb5f..db42d87c 100644
--- a/shell/error_explainer_test.go
+++ b/shell/error_explainer_test.go
@@ -40,7 +40,6 @@ func TestExplainError(t *testing.T) {
 	}
 
 	for _, tt := range testCases {
-		tt := tt
 
 		t.Run(tt.errorOutput, func(t *testing.T) {
 			t.Parallel()
diff --git a/telemetry/meter_test.go b/telemetry/meter_test.go
index 1e283c3d..31bd3136 100644
--- a/telemetry/meter_test.go
+++ b/telemetry/meter_test.go
@@ -56,7 +56,6 @@ func TestNewMetricsExporter(t *testing.T) {
 	}
 
 	for _, tt := range tests {
-		tt := tt
 		t.Run(tt.name, func(t *testing.T) {
 			t.Parallel()
 
@@ -122,7 +121,6 @@ func TestCleanMetricName(t *testing.T) {
 	}
 
 	for _, tc := range testCases {
-		tc := tc
 		t.Run(tc.name, func(t *testing.T) {
 			t.Parallel()
 			result := telemetry.CleanMetricName(tc.input)
diff --git a/telemetry/tracer_test.go b/telemetry/tracer_test.go
index 34793156..cf065505 100644
--- a/telemetry/tracer_test.go
+++ b/telemetry/tracer_test.go
@@ -68,7 +68,6 @@ func TestNewTraceExporter(t *testing.T) {
 	}
 
 	for _, tt := range tests {
-		tt := tt
 		t.Run(tt.name, func(t *testing.T) {
 			t.Parallel()
 
diff --git a/test/fixtures/stacks/terragrunt-dir/live/root.hcl b/test/fixtures/stacks/terragrunt-dir/live/root.hcl
new file mode 100644
index 00000000..e69de29b
diff --git a/test/fixtures/stacks/terragrunt-dir/live/tennant_1/terragrunt.stack.hcl b/test/fixtures/stacks/terragrunt-dir/live/tennant_1/terragrunt.stack.hcl
new file mode 100644
index 00000000..9dc89759
--- /dev/null
+++ b/test/fixtures/stacks/terragrunt-dir/live/tennant_1/terragrunt.stack.hcl
@@ -0,0 +1,7 @@
+unit "unit_a" {
+  source = "../../unit_a"
+  path   = "unit_a"
+  values = {
+    terragrunt_dir = get_terragrunt_dir()
+  }
+}
\ No newline at end of file
diff --git a/test/fixtures/stacks/terragrunt-dir/unit_a/main.tf b/test/fixtures/stacks/terragrunt-dir/unit_a/main.tf
new file mode 100644
index 00000000..d312e7d6
--- /dev/null
+++ b/test/fixtures/stacks/terragrunt-dir/unit_a/main.tf
@@ -0,0 +1,5 @@
+variable "terragrunt_dir" {}
+
+output "terragrunt_dir" {
+  value = var.terragrunt_dir
+}
\ No newline at end of file
diff --git a/test/fixtures/stacks/terragrunt-dir/unit_a/terragrunt.hcl b/test/fixtures/stacks/terragrunt-dir/unit_a/terragrunt.hcl
new file mode 100644
index 00000000..e1ec65f7
--- /dev/null
+++ b/test/fixtures/stacks/terragrunt-dir/unit_a/terragrunt.hcl
@@ -0,0 +1,12 @@
+
+include "root" {
+  path = find_in_parent_folders("root.hcl")
+}
+
+terraform {
+  source = "."
+}
+
+inputs = {
+  terragrunt_dir = values.terragrunt_dir
+}
diff --git a/test/integration_debug_test.go b/test/integration_debug_test.go
index 70342c94..27f15ec8 100644
--- a/test/integration_debug_test.go
+++ b/test/integration_debug_test.go
@@ -101,7 +101,6 @@ func TestTerragruntValidateInputs(t *testing.T) {
 	for _, module := range moduleDirs {
 		// capture range var within range scope so it doesn't change as the tests are spun to the background in the
 		// t.Parallel call.
-		module := module
 
 		name := filepath.Base(module)
 		t.Run(name, func(t *testing.T) {
diff --git a/test/integration_deprecated_test.go b/test/integration_deprecated_test.go
index f8225ff0..bfc7abac 100644
--- a/test/integration_deprecated_test.go
+++ b/test/integration_deprecated_test.go
@@ -30,7 +30,7 @@ func TestDeprecatedHclvalidateCommand_HclvalidateInvalidConfigPath(t *testing.T)
 	}
 
 	stdout, _, err := helpers.RunTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt hclvalidate --terragrunt-working-dir %s --terragrunt-hclvalidate-json --terragrunt-hclvalidate-show-config-path", rootPath))
-	require.NoError(t, err)
+	require.Error(t, err)
 
 	var actualPaths []string
 
diff --git a/test/integration_report_test.go b/test/integration_report_test.go
index 49943e59..020c9661 100644
--- a/test/integration_report_test.go
+++ b/test/integration_report_test.go
@@ -134,7 +134,7 @@ func TestTerragruntReportExperimentSaveToFile(t *testing.T) {
 	}
 
 	for _, tc := range testCases {
-		tc := tc // capture range variable
+		// capture range variable
 		t.Run(tc.name, func(t *testing.T) {
 			t.Parallel()
 
@@ -323,7 +323,7 @@ func TestTerragruntReportExperimentSaveToFileWithFormat(t *testing.T) {
 				assert.True(t, strings.HasPrefix(string(content), "Name,Started,Ended,Result,Reason,Cause"))
 			case "json":
 				// For JSON, verify it's valid JSON and has the expected structure
-				var jsonContent []map[string]interface{}
+				var jsonContent []map[string]any
 				err := json.Unmarshal(content, &jsonContent)
 
 				require.NoError(t, err)
@@ -348,7 +348,7 @@ func TestTerragruntReportExperimentSaveToFileWithFormat(t *testing.T) {
 				require.NoError(t, err)
 
 				// Verify it's valid JSON
-				var schema map[string]interface{}
+				var schema map[string]any
 				err = json.Unmarshal(schemaContent, &schema)
 				require.NoError(t, err)
 
@@ -358,11 +358,11 @@ func TestTerragruntReportExperimentSaveToFileWithFormat(t *testing.T) {
 				assert.Equal(t, "Terragrunt Run Report Schema", schema["title"])
 
 				// Verify items schema
-				items, ok := schema["items"].(map[string]interface{})
+				items, ok := schema["items"].(map[string]any)
 				require.True(t, ok)
 
 				// Verify required fields
-				required, ok := items["required"].([]interface{})
+				required, ok := items["required"].([]any)
 				require.True(t, ok)
 				assert.Contains(t, required, "Name")
 				assert.Contains(t, required, "Started")
@@ -370,14 +370,14 @@ func TestTerragruntReportExperimentSaveToFileWithFormat(t *testing.T) {
 				assert.Contains(t, required, "Result")
 
 				// Verify properties
-				properties, ok := items["properties"].(map[string]interface{})
+				properties, ok := items["properties"].(map[string]any)
 				require.True(t, ok)
 
 				// Verify field types
-				assert.Equal(t, "string", properties["Name"].(map[string]interface{})["type"])
-				assert.Equal(t, "string", properties["Result"].(map[string]interface{})["type"])
-				assert.Equal(t, "string", properties["Started"].(map[string]interface{})["type"])
-				assert.Equal(t, "string", properties["Ended"].(map[string]interface{})["type"])
+				assert.Equal(t, "string", properties["Name"].(map[string]any)["type"])
+				assert.Equal(t, "string", properties["Result"].(map[string]any)["type"])
+				assert.Equal(t, "string", properties["Started"].(map[string]any)["type"])
+				assert.Equal(t, "string", properties["Ended"].(map[string]any)["type"])
 			}
 		})
 	}
@@ -508,7 +508,7 @@ func TestReportWithExternalDependenciesExcluded(t *testing.T) {
 	require.NoError(t, err)
 
 	// Verify that the report file contains the expected content
-	var report []map[string]interface{}
+	var report []map[string]any
 	err = json.Unmarshal(reportContent, &report)
 	require.NoError(t, err)
 
diff --git a/test/integration_stacks_test.go b/test/integration_stacks_test.go
index bcfe2a48..ef05c782 100644
--- a/test/integration_stacks_test.go
+++ b/test/integration_stacks_test.go
@@ -47,6 +47,7 @@ const (
 	testFixtureStackSelfInclude                = "fixtures/stacks/self-include"
 	testFixtureStackNestedOutputs              = "fixtures/stacks/nested-outputs"
 	testFixtureStackNoValidation               = "fixtures/stacks/no-validation"
+	testFixtureStackTerragruntDir              = "fixtures/stacks/terragrunt-dir"
 )
 
 func TestStacksGenerateBasic(t *testing.T) {
@@ -1296,3 +1297,20 @@ func validateStackDir(t *testing.T, path string) {
 
 	assert.True(t, hasSubdirectories, "The .terragrunt-stack directory should contain at least one subdirectory")
 }
+
+func TestStackTerragruntDir(t *testing.T) {
+	t.Parallel()
+
+	helpers.CleanupTerraformFolder(t, testFixtureStackTerragruntDir)
+	tmpEnvPath := helpers.CopyEnvironment(t, testFixtureStackTerragruntDir)
+	gitPath := util.JoinPath(tmpEnvPath, testFixtureStackTerragruntDir)
+	helpers.CreateGitRepo(t, gitPath)
+	rootPath := util.JoinPath(gitPath, "live")
+
+	_, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt stack generate --no-stack-validate --working-dir "+rootPath)
+	require.NoError(t, err)
+
+	out, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt apply --all --non-interactive --working-dir "+rootPath)
+	require.NoError(t, err)
+	assert.Contains(t, out, `terragrunt_dir = "./tennant_1"`)
+}
diff --git a/test/integration_test.go b/test/integration_test.go
index ddc029ce..e3f3577c 100644
--- a/test/integration_test.go
+++ b/test/integration_test.go
@@ -702,7 +702,7 @@ func TestHclvalidateDiagnostic(t *testing.T) {
 	}
 
 	stdout, _, err := helpers.RunTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt hcl validate --working-dir %s --json", rootPath))
-	require.NoError(t, err)
+	require.Error(t, err)
 
 	var actualDiags diagnostic.Diagnostics
 
@@ -712,6 +712,24 @@ func TestHclvalidateDiagnostic(t *testing.T) {
 	assert.ElementsMatch(t, expectedDiags, actualDiags)
 }
 
+func TestHclvalidateReturnsNonZeroExitCodeOnError(t *testing.T) {
+	t.Parallel()
+
+	helpers.CleanupTerraformFolder(t, testFixtureHclvalidate)
+	tmpEnvPath := helpers.CopyEnvironment(t, testFixtureHclvalidate)
+	rootPath := util.JoinPath(tmpEnvPath, testFixtureHclvalidate)
+
+	// We expect an error because the fixture has HCL validation issues.
+	// The content of stdout and stderr isn't the primary focus here,
+	// rather the fact that an error (non-zero exit code) is returned.
+	_, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt hcl validate --working-dir "+rootPath)
+	require.Error(t, err, "terragrunt hcl validate should return a non-zero exit code on HCL errors")
+
+	// As an additional check, we can verify that the error message indicates HCL validation errors.
+	// This makes the test more robust.
+	assert.Contains(t, err.Error(), "HCL validation error(s) found")
+}
+
 func TestHclvalidateInvalidConfigPath(t *testing.T) {
 	t.Parallel()
 
@@ -725,7 +743,7 @@ func TestHclvalidateInvalidConfigPath(t *testing.T) {
 	}
 
 	stdout, _, err := helpers.RunTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt hcl validate --working-dir %s --json --show-config-path", rootPath))
-	require.NoError(t, err)
+	require.Error(t, err)
 
 	var actualPaths []string
 
diff --git a/test/integration_tofu_state_encryption_test.go b/test/integration_tofu_state_encryption_test.go
index 20ec407f..bf4095aa 100644
--- a/test/integration_tofu_state_encryption_test.go
+++ b/test/integration_tofu_state_encryption_test.go
@@ -87,13 +87,13 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 	jsonBytes, err := os.ReadFile(jsonOut)
 	require.NoError(t, err)
 
-	var rendered map[string]interface{}
+	var rendered map[string]any
 	require.NoError(t, json.Unmarshal(jsonBytes, &rendered))
 
 	// Make sure all terraform block is visible
 	terraformBlock, hasTerraform := rendered["terraform"]
 	if assert.True(t, hasTerraform) {
-		source, hasSource := terraformBlock.(map[string]interface{})["source"]
+		source, hasSource := terraformBlock.(map[string]any)["source"]
 		assert.True(t, hasSource)
 		assert.Equal(t, "./module", source)
 	}
@@ -103,23 +103,23 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 	if assert.True(t, hasRemoteState) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
+			map[string]any{
 				"backend": "local",
-				"generate": map[string]interface{}{
+				"generate": map[string]any{
 					"path":      "backend.tf",
 					"if_exists": "overwrite_terragrunt",
 				},
-				"config": map[string]interface{}{
+				"config": map[string]any{
 					"path": "foo.tfstate",
 				},
-				"encryption": map[string]interface{}{
+				"encryption": map[string]any{
 					"key_provider": "pbkdf2",
 					"passphrase":   "correct-horse-battery-staple",
 				},
 				"disable_init":                    false,
 				"disable_dependency_optimization": false,
 			},
-			remoteState.(map[string]interface{}),
+			remoteState.(map[string]any),
 		)
 	}
 
@@ -128,8 +128,8 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 	if assert.True(t, hasDependency) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
-				"dep": map[string]interface{}{
+			map[string]any{
+				"dep": map[string]any{
 					"name":         "dep",
 					"config_path":  "../dep",
 					"outputs":      nil,
@@ -142,7 +142,7 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 					"skip":                                    nil,
 				},
 			},
-			dependencyBlocks.(map[string]interface{}),
+			dependencyBlocks.(map[string]any),
 		)
 	}
 
@@ -151,8 +151,8 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 	if assert.True(t, hasGenerate) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
-				"provider": map[string]interface{}{
+			map[string]any{
+				"provider": map[string]any{
 					"path":              "provider.tf",
 					"comment_prefix":    "# ",
 					"disable_signature": false,
@@ -166,7 +166,7 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 `,
 				},
 			},
-			generateBlocks.(map[string]interface{}),
+			generateBlocks.(map[string]any),
 		)
 	}
 
@@ -175,13 +175,13 @@ func TestTofuRenderJSONConfigWithEncryption(t *testing.T) {
 	if assert.True(t, hasInputs) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
+			map[string]any{
 				"env":        "qa",
 				"name":       "dep",
 				"type":       "main",
 				"aws_region": "us-east-1",
 			},
-			inputsBlock.(map[string]interface{}),
+			inputsBlock.(map[string]any),
 		)
 	}
 }
@@ -201,13 +201,13 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 	jsonBytes, err := os.ReadFile(jsonOut)
 	require.NoError(t, err)
 
-	var rendered map[string]interface{}
+	var rendered map[string]any
 	require.NoError(t, json.Unmarshal(jsonBytes, &rendered))
 
 	// Make sure all terraform block is visible
 	terraformBlock, hasTerraform := rendered["terraform"]
 	if assert.True(t, hasTerraform) {
-		source, hasSource := terraformBlock.(map[string]interface{})["source"]
+		source, hasSource := terraformBlock.(map[string]any)["source"]
 		assert.True(t, hasSource)
 		assert.Equal(t, "./module", source)
 	}
@@ -217,23 +217,23 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 	if assert.True(t, hasRemoteState) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
+			map[string]any{
 				"backend": "local",
-				"generate": map[string]interface{}{
+				"generate": map[string]any{
 					"path":      "backend.tf",
 					"if_exists": "overwrite_terragrunt",
 				},
-				"config": map[string]interface{}{
+				"config": map[string]any{
 					"path": "foo.tfstate",
 				},
-				"encryption": map[string]interface{}{
+				"encryption": map[string]any{
 					"key_provider": "pbkdf2",
 					"passphrase":   "correct-horse-battery-staple",
 				},
 				"disable_init":                    false,
 				"disable_dependency_optimization": false,
 			},
-			remoteState.(map[string]interface{}),
+			remoteState.(map[string]any),
 		)
 	}
 
@@ -242,8 +242,8 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 	if assert.True(t, hasDependency) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
-				"dep": map[string]interface{}{
+			map[string]any{
+				"dep": map[string]any{
 					"name":         "dep",
 					"config_path":  "../dep",
 					"outputs":      nil,
@@ -256,7 +256,7 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 					"skip":                                    nil,
 				},
 			},
-			dependencyBlocks.(map[string]interface{}),
+			dependencyBlocks.(map[string]any),
 		)
 	}
 
@@ -265,8 +265,8 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 	if assert.True(t, hasGenerate) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
-				"provider": map[string]interface{}{
+			map[string]any{
+				"provider": map[string]any{
 					"path":              "provider.tf",
 					"comment_prefix":    "# ",
 					"disable_signature": false,
@@ -280,7 +280,7 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 `,
 				},
 			},
-			generateBlocks.(map[string]interface{}),
+			generateBlocks.(map[string]any),
 		)
 	}
 
@@ -289,13 +289,13 @@ func TestTofuRenderJSONConfigWithEncryptionExp(t *testing.T) {
 	if assert.True(t, hasInputs) {
 		assert.Equal(
 			t,
-			map[string]interface{}{
+			map[string]any{
 				"env":        "qa",
 				"name":       "dep",
 				"type":       "main",
 				"aws_region": "us-east-1",
 			},
-			inputsBlock.(map[string]interface{}),
+			inputsBlock.(map[string]any),
 		)
 	}
 }
@@ -313,7 +313,7 @@ func validateStateIsEncrypted(t *testing.T, fileName string, path string) {
 	byteValue, err := io.ReadAll(file)
 	require.NoError(t, err)
 
-	var result map[string]interface{}
+	var result map[string]any
 	err = json.Unmarshal(byteValue, &result)
 	require.NoError(t, err, "Error unmarshalling the state file '%s'", fileName)