Skip to content

Commit 1d63937

Browse files
committed
Added PlanFilesJsonRelativePath
1 parent 6fd355a commit 1d63937

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/runner/common/unit.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,18 @@ func (unit *Unit) getPlanFilePath(l log.Logger, opts *options.TerragruntOptions,
9999
dir := filepath.Join(outputFolder, path)
100100

101101
if !filepath.IsAbs(dir) {
102-
dir = filepath.Join(opts.WorkingDir, dir)
102+
// Resolve relative output folder against root working directory, not the unit working directory
103+
// so that artifacts for all units are stored under a single root-level out dir structure.
104+
base := opts.RootWorkingDir
105+
if !filepath.IsAbs(base) {
106+
// In case RootWorkingDir is somehow relative, resolve it first.
107+
if absBase, err := filepath.Abs(base); err == nil {
108+
base = absBase
109+
} else {
110+
l.Warnf("Failed to get absolute path for root working dir %s: %v", base, err)
111+
}
112+
}
113+
dir = filepath.Join(base, dir)
103114
if absDir, err := filepath.Abs(dir); err == nil {
104115
dir = absDir
105116
} else {

0 commit comments

Comments
 (0)