Error - no such file or directory

Hi guys, I’m new to terragrunt and I’ve already been able to do some tasks, but I’m having a hard time, when I try to run the command it shows the following error, can someone help me please:

no such file or directory

My structure is in the following diagram:

.
├── README.md
├── aws
│ ├── ecs-cluster-tools
│ │ ├── dev
│ │ │ └── terragrunt.hcl
│ │ └── prd
│ │
│ ├── ecs-service-tools
│ │ ├── dev
│ │ │
│ │ └── prd
│ │
│ └── network
│ ├── dev
│ │
│ └── prd

└── terragrunt.hcl

I’m running the following command:

terragrunt run-all plan --terragrunt-source aws/ecs-cluster-tools/dev/

In the root file I only have the blocks (locals, generate provider and remote state).

In the terragrunt.hcl file inside (aws/ecs-cluster-tools/dev/terragrunt.hcl):

include {
  path = find_in_parent_folders()
}

terraform {
  source = "git::git@<URL_GIT>terraform-ecs-cluster/devops-tools.git//module?ref=1.0.3"
}

It duplicates folders, as below:

Expected
terragunt/aws/ecs-cluster-tools/dev

What he returns
terragunt/aws/ecs-cluster-tools/dev/aws/ecs-cluster-tools/dev

Error:
INFO[0000] Stack at /terragunt:
=> Module /terragunt/aws/ecs-cluster-tools/dev (excluded: false, dependencies: )
ERRO[0001] Module /terragunt/aws/ecs-cluster-tools/dev has finished with an error: 1 error occurred:
* stat /terragunt/aws/ecs-cluster-tools/dev/aws/ecs-cluster-tools/dev: no such file or directory
prefix=[/terragunt/aws/ecs-cluster-tools/dev]
ERRO[0001] 1 error occurred:
* stat /terragunt/aws/ecs-cluster-tools/dev/aws/ecs-cluster-tools/dev: no such file or directory

ERRO[0001] Unable to determine underlying exit code, so Terragrunt will exit with error code 1

But if I run terragrunt with the terraform modules not inside the dev folder the terragrunt can run without problem.

NOTE: If I run without the parameter “–terragrunt-source” the terragrunt passes successfully, but this structure created will be to serve several modules and they will not be created simultaneously, that’s why I point the “–terragrunt-source” together to the command.

Terraform: v1.0.5
Terragrunt: v0.31.0

Thank you

Hi,

I think you might be misunderstanding what the terragrunt-source parameter is trying to achieve. The --terragrunt-source parameter replaces the source attribute of the terraform block. So what you are doing is equivalent to:

include {
  path = find_in_parent_folders()
}

terraform {
  source = "aws/ecs-cluster-tools/dev/"
}

Which won’t work because there is no terraform module at the path you give it. The use case served by --terragrunt-source is for local development of updates to modules.

Is what you are trying to achieve to replicate a given configuration against multiple target accounts? If so, unfortunately, terragrunt currently doesn’t support what you are trying to achieve here, as it is a fundamental difference in the design philosophy. Terragrunt is going for explicit over implicit, and having physical files representing the deployed modules is one of the design choices for being explicit about what modules are deployed. The closest thing to what you want in terragrunt is to have the configuration as an _envcommon config that gets included for each deployment. But in that case, you will still need a separate terragrunt file for each deployed component (see Keep your Terragrunt Architecture DRY for more info on this pattern).

Hope this helps!

Best regards,
Yori