gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
7.99k stars 970 forks source link

Terragrunt v0.17.4 | `apply-all` in combination with `--terragrunt-working-dir` not working properly #641

Open TheWolfNL opened 5 years ago

TheWolfNL commented 5 years ago

Output when adding TERRAGRUNT_DEBUG='true':

Running: terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir test/dir
[terragrunt] [test/dir] 2019/01/25 14:45:28 Running command: terraform --version
[terragrunt] 2019/01/25 14:45:28 Reading Terragrunt config file at test/dir/terraform.tfvars
[terragrunt] 2019/01/25 14:45:28 *os.PathError Error reading file at path test/dir/terraform.tfvars: open test/dir/terraform.tfvars: no such file or directory
/go/src/github.com/gruntwork-io/terragrunt/errors/errors.go:26 (0x4eee33)
/go/src/github.com/gruntwork-io/terragrunt/util/file.go:134 (0x520bd1)
/go/src/github.com/gruntwork-io/terragrunt/config/config.go:269 (0x865283)
/go/src/github.com/gruntwork-io/terragrunt/config/config.go:259 (0x8651ce)
/go/src/github.com/gruntwork-io/terragrunt/cli/cli_app.go:224 (0x8fa0da)
/go/src/github.com/gruntwork-io/terragrunt/cli/cli_app.go:214 (0x8fa060)
/go/src/github.com/gruntwork-io/terragrunt/cli/cli_app.go:195 (0x8f9d2e)
/go/src/github.com/gruntwork-io/terragrunt/vendor/github.com/urfave/cli/app.go:502 (0x897952)
/go/src/github.com/gruntwork-io/terragrunt/vendor/github.com/urfave/cli/app.go:268 (0x895823)
/go/src/github.com/gruntwork-io/terragrunt/main.go:20 (0x9018f4)
/usr/local/go/src/runtime/proc.go:195 (0x42bd66)
/usr/local/go/src/runtime/asm_amd64.s:2337 (0x458c81)

Dir structure:

test/
├── terraform.tfvars
└── dir/
    ├── module A/
    │   └── terraform.tfvars
    └── module B/
        └── terraform.tfvars
--

I'm running this with the working-dir because I want to apply everything inside the test/dir but apparently since the stack notes cli/cli_app.go:214 that means that apply-all isn't properly recognised as a Multi-command. isMultiModuleCommand(command) in cli/cli_app.go:211.

brikis98 commented 5 years ago

Hm, that seems odd... What version of Terragrunt?

TheWolfNL commented 5 years ago

Upon some further investigation the problem seems to originate in the version check. since the terragrunt's apply-all doesn't use the config file, setting the TERRAGRUNT_CONFIG will allow you to continue, but will then get stuck a bit later.

Running: terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir test/dir
[terragrunt] [test] 2019/01/28 13:10:46 Running command: terraform --version
[terragrunt] 2019/01/28 13:10:46 Reading Terragrunt config file at test/dir/../terraform.tfvars
[terragrunt] [test] 2019/01/28 13:10:46 Initializing remote state for the gcs backend
[terragrunt] [test] 2019/01/28 13:10:46 Running command: terraform init -backend-config=bucket=terraform-test-state -backend-config=prefix=. -backend-config=project=terraform
Terraform initialized in an empty directory!

The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.
[terragrunt] 2019/01/28 13:10:46 Running command: terraform @
Usage: terraform [-version] [-help] <command> [args]
TheWolfNL commented 5 years ago

@brikis98 Terragrunt version v0.17.4