Hey All, My terragrunt structure - ```. ├── _envc...
# help
b
Hey All, My terragrunt structure -
Copy code
.
├── _envcommon/
│   ├── vpc.hcl
│   └── endpoint.hcl
└── live/
    ├── prod
    └── green/
        └── vpc/
            ├── endpoint/
            │   └── terragrunt.hcl
            └── terragrunt.hcl
I am running
infracost breakdown --path=.
at
live/green/
however, I am receiving this error:
Copy code
live/greenng/vpc/_envcommon/endpoint.hcl:
          no such file or directory
Inside this
endpoint/terragrunt.hcl
we have:
Copy code
include "envcommon" {
  path = "${dirname(find_in_parent_folders())}/_envcommon/endpoint.hcl"
}
It seems when there is a sub directory and a terragrunt.hcl file it will throw this error; whereas if I remove this endpoint folder it will work, where the
vpc/terragrunt.hcl
contains the same
envcommon
include apart from
endpoint.hcl
its
vpc.hcl
Any ideas?
l
Hi @brief-ice-47661 which directory do you normally run the
terragrunt
commands from? Both
live/green/vpc
and
live/green/vpc/endpoint
?
Also can you try running the following from `live/green/`:
Copy code
infracost breakdown --path=. --exclude-path endpoint
b
Hey @little-author-61621 I run terragrunt from within either of the following:
live/green
live/green/vpc
and
live/green/vpc/endpoint
and no issues
l
Does it work at all with the
--exclude-path
option?
b
@little-author-61621 If I exclude
vpc/endpoint
it does work
How would I be able to make it work without excluding it? As I will have other sub directories for organisation
l
Would something like this work?
Copy code
infracost breakdown --path=. --exclude-path="**/**/terragrunt.hcl"
The issue is we run similar logic to
terragrunt run-all
when you pass a path that has multiple directories with
terragrunt.hcl
files under it, so this is trying to exclude any of those children Terragrunt projects. p.s. please don’t send all responses to the channel, there’s 506 people who get notified when that happens.
b
Ah apologises; but wouldn't that exclude the terragrunt configuration? So I wouldn't be able to breakdown costs?
l
Would creating an
infracost.yml
config file help:
Copy code
version: 0.1
projects:
  - path: live/green/vpc
    exclude_paths:
      - "**/terragrunt.hcl"
  - path: live/green/vpc/endpoint
    exclude_paths:
      - "**/terragrunt.hcl"
And running
infracost breakdown --config-file=infracost.yml
b
Copy code
live/green/vpc/_envcommon/endpoint.hcl: no such file or directory
I think its thinking the vpc is the full parent
l
hmm, maybe I’m not understanding Terragrunt correctly but when I try to replicate this locally I get the same error running
terragrunt plan
in
live/green/vpc/endpoint
.
https://terragrunt.gruntwork.io/docs/reference/built-in-functions/#find_in_parent_folders
find_in_parent_folders()
searches up the directory tree from the current
terragrunt.hcl
file and returns the absolute path to the first
terragrunt.hcl
in a parent folder or exit with an error if no such file is found.
Which for the case of
live/green/vpc/endpoint
would be the
live/green/vpc
no?
b
Good point; that is an oversight on my part, I do apologise
l
No worries, let me know how the config file works out.
b
I am running
infracost breakdown --path=.
at
live/green/
however, I am receiving this error:
```live/greenng/vpc/_envcommon/endpoint.hcl:
no such file or directory```
I see
green
and
greenng
is that an editing typo or ... ?