Skip to content

Commit 320557b

Browse files
authored
Merge pull request #126 from gruntwork-io/fix-cleanup
When cleaning up files, don't delete files in .terraform folders
2 parents 0bd7827 + c428eb9 commit 320557b

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

cli/download_source.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,17 @@ func cleanupTerraformFiles(path string, terragruntOptions *options.TerragruntOpt
318318
if err != nil {
319319
return errors.WithStackTrace(err)
320320
}
321-
return util.DeleteFiles(files)
321+
322+
// Filter out files in .terraform folders, since those are from modules downloaded via a call to terraform get,
323+
// and we don't want to re-download them.
324+
filteredFiles := []string{}
325+
for _, file := range files {
326+
if !strings.Contains(file, ".terraform") {
327+
filteredFiles = append(filteredFiles, file)
328+
}
329+
}
330+
331+
return util.DeleteFiles(filteredFiles)
322332
}
323333

324334
// There are two ways a user can tell Terragrunt that it needs to download Terraform configurations from a specific

test/fixture-download/hello-world/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ output "test" {
1212

1313
module "hello" {
1414
source = "./hello"
15+
}
16+
17+
module "remote" {
18+
source = "github.com/gruntwork-io/terragrunt.git//test/fixture-download/hello-world?ref=v0.9.9"
19+
name = "${var.name}"
1520
}

0 commit comments

Comments
 (0)