Skip to content

Commit 916bdfc

Browse files
authored
Merge pull request #535 from prupe/download-dir-env
Configure terragrunt-download-dir via environment variable
2 parents c9fc53e + 0adf5ed commit 916bdfc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,8 +1763,8 @@ start with the prefix `--terragrunt-`. The currently available options are:
17631763
subfolders of the `terragrunt-working-dir`, running `terraform` in the root of each module it finds.
17641764
17651765
* `--terragrunt-download-dir`: The path where to download Terraform code when using [remote Terraform
1766-
configurations](#keep-your-terraform-code-dry). Default is `.terragrunt-cache` in the working directory. We recommend
1767-
adding this folder to your `.gitignore`.
1766+
configurations](#keep-your-terraform-code-dry). May also be specified via the `TERRAGRUNT_DOWNLOAD` environment
1767+
variable. Default is `.terragrunt-cache` in the working directory. We recommend adding this folder to your `.gitignore`.
17681768
17691769
* `--terragrunt-source`: Download Terraform configurations from the specified source into a temporary folder, and run
17701770
Terraform in that temporary folder. May also be specified via the `TERRAGRUNT_SOURCE` environment variable. The
@@ -1858,6 +1858,9 @@ delete all of them as follows:
18581858
find . -type d -name ".terragrunt-cache" -prune -exec rm -rf {} \;
18591859
```
18601860
1861+
Also consider setting the `TERRAGRUNT_DOWNLOAD` environment variable if you wish to place the cache directories
1862+
somewhere else.
1863+
18611864
18621865
18631866

cli/args.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ func parseTerragruntOptionsFromArgs(args []string, writer, errWriter io.Writer)
4545
return nil, err
4646
}
4747

48-
downloadDirRaw, err := parseStringArg(args, OPT_DOWNLOAD_DIR, util.JoinPath(workingDir, options.TerragruntCacheDir))
48+
downloadDirRaw, err := parseStringArg(args, OPT_DOWNLOAD_DIR, os.Getenv("TERRAGRUNT_DOWNLOAD"))
4949
if err != nil {
5050
return nil, err
5151
}
52+
if downloadDirRaw == "" {
53+
downloadDirRaw = util.JoinPath(workingDir, options.TerragruntCacheDir)
54+
}
5255
downloadDir, err := filepath.Abs(downloadDirRaw)
5356
if err != nil {
5457
return nil, errors.WithStackTrace(err)

0 commit comments

Comments
 (0)