@@ -373,6 +373,12 @@ func Parse(
373373 case * component.Stack :
374374 configFilename = config .DefaultStackFile
375375 default :
376+ if unit , ok := c .(* component.Unit ); ok && unit .ConfigFile () != "" {
377+ configFilename = unit .ConfigFile ()
378+
379+ break
380+ }
381+
376382 if opts .TerragruntConfigPath != "" && ! util .IsDir (opts .TerragruntConfigPath ) {
377383 configFilename = filepath .Base (opts .TerragruntConfigPath )
378384 }
@@ -691,11 +697,10 @@ func (d *Discovery) processFile(
691697 // If the directory is hidden, allow it only if it matches an include pattern
692698 allowHidden := false
693699
694- if canErr == nil {
695- // Always allow .terragrunt-stack contents
696- cleanDir := util .CleanPath (canonicalDir )
697- allowHidden = isInStackDirectory (cleanDir )
698- }
700+ // Always allow .terragrunt-stack contents. We can safely use the non-canonical
701+ // dir here because this branch is only reached when canonical path computation
702+ // failed, or when we couldn't early-return with a concrete component.
703+ allowHidden = isInStackDirectory (filepath .ToSlash (dir ))
699704
700705 if ! allowHidden {
701706 return nil
@@ -725,6 +730,9 @@ func (d *Discovery) createComponentFromPath(path string, filenames []string) com
725730 }
726731
727732 c := componentOfBase (dir , base )
733+ if unit , ok := c .(* component.Unit ); ok {
734+ unit .SetConfigFile (base )
735+ }
728736
729737 if d .discoveryContext != nil {
730738 c .SetDiscoveryContext (d .discoveryContext )
0 commit comments