Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/v1.13/ENHANCEMENTS-20250408-130152.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: Terraform will use the value of TF_DATA_DIR for temporary files when installing providers, gracefully falling back to os.TempDir if it's unset.
time: 2025-04-08T13:01:52.791835-03:00
custom:
Issue: "36863"
3 changes: 2 additions & 1 deletion internal/cloudplugin/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func (v BinaryManager) resolveRelease() (*Binary, error) {
}

// Download the archive
t, err := os.CreateTemp(os.TempDir(), "terraform-cloudplugin")
// if TF_DATA_DIR is unset, it defaults to "", which results in using TMPDIR or /tmp
t, err := os.CreateTemp(os.Getenv("TF_DATA_DIR"), "terraform-cloudplugin")
if err != nil {
return nil, fmt.Errorf("failed to create temp file for download: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/providercache/package_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func installFromHTTPURL(ctx context.Context, meta getproviders.PackageMeta, targ
// registry source.
return nil, fmt.Errorf("invalid provider download request: %s", err)
}
f, err := os.CreateTemp("", "terraform-provider")
// if TF_DATA_DIR is unset, it defaults to "", which results in using TMPDIR or /tmp
f, err := os.CreateTemp(os.Getenv("TF_DATA_DIR"), "terraform-provider")
if err != nil {
return nil, fmt.Errorf("failed to open temporary file to download from %s: %w", urlStr, err)
}
Expand Down