terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

terragrunt run-all fmt does not write changes

Open crablab opened this issue 2 years ago • 2 comments

Command: terragrunt run-all fmt

Expected behaviour: Terragrunt runs terraform fmt in modules, outputting files that have formatting errors and modifying them to meet the format. In other words, the default behaviour of fmt.

Actual behaviour: fmt runs and outputs a list of files that don't meet the standard, but doesn't make changes to these files. Setting -write=true makes no difference.

Is this expected? It's odd to me that the fmt behaviour is as expected, except for persisting the formatting corrections to disk.

crablab avatar May 30 '22 09:05 crablab

Hi, afaik formatting of files is executed on files, maybe occurs an error during processing of files? adding --terragrunt-log-level debug to terragrunt may help to show what happens inside

A simplified example for terragrunt that modify files when is invoked terragrunt run-all fmt: https://github.com/denis256/terragrunt-tests/tree/master/issue-2127

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ terragrunt run-all fmt
Group 1
- Module /home/denis/projects/gruntwork/terragrunt-tests/issue-2127/module1
- Module /home/denis/projects/gruntwork/terragrunt-tests/issue-2127/module2

Group 2
- Module /home/denis/projects/gruntwork/terragrunt-tests/issue-2127/app
 
main.tf
main.tf
main.tf

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   app/main.tf
        modified:   module1/main.tf
        modified:   module2/main.tf

denis256 avatar May 30 '22 12:05 denis256

Apart from the logline

DEBU[0004] Running command: terraform fmt 

afraid I don't see anything of relevance in the log outputs.

I can say that it is not modifying any files for certain.

crablab avatar May 30 '22 14:05 crablab