https://infracost.io logo
#help
Title
# help
b

brief-ice-47661

12/05/2023, 4:43 PM
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

little-author-61621

12/05/2023, 5:25 PM
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

brief-ice-47661

12/05/2023, 5:36 PM
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

little-author-61621

12/05/2023, 5:40 PM
Does it work at all with the
--exclude-path
option?
b

brief-ice-47661

12/05/2023, 5:43 PM
@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

little-author-61621

12/05/2023, 6:02 PM
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

brief-ice-47661

12/05/2023, 6:03 PM
Ah apologises; but wouldn't that exclude the terragrunt configuration? So I wouldn't be able to breakdown costs?
l

little-author-61621

12/05/2023, 6:05 PM
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

brief-ice-47661

12/05/2023, 6:13 PM
Copy code
live/green/vpc/_envcommon/endpoint.hcl: no such file or directory
I think its thinking the vpc is the full parent
l

little-author-61621

12/05/2023, 6:23 PM
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

brief-ice-47661

12/05/2023, 6:43 PM
Good point; that is an oversight on my part, I do apologise
l

little-author-61621

12/05/2023, 6:52 PM
No worries, let me know how the config file works out.
b

bored-actor-81445

12/14/2023, 9:56 AM
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 ... ?