terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

Terrragrunt run-all init does not work if a dependency backend is uninitialized

Open x-Xymos opened this issue 2 years ago • 3 comments

I have the following project structure:

  • environments
    • dev
      • local
        • service1/terragrunt.hcl
        • service2/terragrunt.hcl
        • service3/terragrunt.hcl
        • k8s/terragrunt.hcl

All services depends on some outputs from the k8s component, when I try to run terragrunt run-all init inside of environments/dev/local and none of the modules or their backends have been initialized, the stack groups are not shown I get an error

root@master:/tmp/environments/local/dev# terragrunt run-all init
ERRO[0006] Module /tmp/environments/local/dev/service1 specifies /tmp/environments/local/dev/service1/../k8s/ as a dependency, but that dependency was not one of the ones found while scanning subfolders: [/tmp/environments/local/dev/service1/terragrunt.hcl
ERRO[0006] Unable to determine underlying exit code, so Terragrunt will exit with error code 1 

I can work around this by: cd into k8s folder, run terragrunt init

root@master:/tmp/environments/local/dev/k8s# terragrunt init

Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding latest version of hashicorp/local...
- Finding latest version of hashicorp/azurerm...
- Installing hashicorp/local v2.2.3...
- Installed hashicorp/local v2.2.3 (signed by HashiCorp)
- Installing hashicorp/azurerm v3.20.0...
- Installed hashicorp/azurerm v3.20.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
  • cd back into environments/dev/local
  • now I can run terragrunt run-all init
root@master:/tmp/environments/local/dev/k8s# cd ..
root@master:/tmp/environments/local/dev# terragrunt run-all init
INFO[0003] The stack at /tmp/environments/local/dev will be processed in the following order for command init:
Group 1
- Module /tmp/environments/local/dev/k8s

Group 2
- Module /tmp/environments/local/dev/service1

This is not ideal as I can't initialize everything with a single command and I have to implement custom functionality into my script to work around this.

x-Xymos avatar Aug 26 '22 13:08 x-Xymos

Any light on this issue? I am coming across the very same thing. One might think it is looking for exact path matches, however, even if you use absolute paths it still displays the same error.

ERRO[0008] Module /home/sergiojoker11/github-repos/terragrunt/environments/flexys/pentest/aiven_keystores specifies /home/sergiojoker11/github-repos/terragrunt/environments/flexys/pentest/project/ as a dependency, but that dependency was not one of the ones found while scanning subfolders: [
...omitted sublist...
 /home/sergiojoker11/github-repos/terragrunt/environments/flexys/pentest/project/terragrunt.hcl 
]

sergiojoker11 avatar Jan 31 '23 16:01 sergiojoker11

I came across with this same issue, and noticed that as a workaround I could just create some dummy .tf file in the dependency project.

touch environments/local/dev/k8s/something.tf

And the terragrunt run-all init should work.

tpokki avatar Jun 05 '23 12:06 tpokki

I had the same issue: Module $module_name specifies $deps_path as a dependency, but that dependency was not one of the ones found while scanning subfolders:

after mocking output and adding .tf file to module folder problem was solved, but i think it should be fixed.

michal-maslaniec-tf avatar Feb 02 '24 21:02 michal-maslaniec-tf