terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

Issue with find_in_parent_folders function

Open yadamovych opened this issue 1 year ago • 7 comments

Describe the bug

Hi everyone,

I'm still experiencing this issue with find_in_parent_folders in the latest version.

Seems this is a duplication of #2941

Error:
ERRO[0001] Error: Error in function call
ERRO[0001] on infrastructure/template/main/general/stage/customer-features/eks/k8s/terragrunt.hcl line 6, in locals:
ERRO[0001] 6: account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
ERRO[0001] Call to function "find_in_parent_folders" failed: ParentFileNotFoundError: Could not find an account.hcl in any of the parent folders of saas-test1/infrastructure/template/main/general/stage/network/terragrunt.hcl. Traversed all the way to the root.

Could someone please assist in resolving this?

Thanks for your help!

Steps To Reproduce

In the root of our Git repository, there are folders for deployment and infrastructure. When I execute one of the deployment configurations, it contains a dependency on infrastructure.

dependency "eks" {
  config_path = "../../../../../../../infrastructure/accounts/qa-dev/eu-central-1/devx/customer-features/eks/k8s-main"
}

The dependent infrastructure module includes a template file:

include "template" {
  path = "infrastructure/template/main/general/stage/customer-features/eks/k8s/terragrunt.hcl"
}

The Terragrunt configuration template includes a local block that utilizes the find_in_parent_folders function, which leads to Issues following Terraform version 0.55.1.

locals {
  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
  region_vars  = read_terragrunt_config(find_in_parent_folders("regional.hcl"))
  stage_vars   = read_terragrunt_config(find_in_parent_folders("stage.hcl"))
}

Config files are located here: saas-test1/infrastructure/accounts/qa-dev/eu-central-1/devx/stage.hcl saas-test1/infrastructure/accounts/qa-dev/eu-central-1/regional.hcl saas-test1/infrastructure/accounts/qa-dev/account.hcl

Expected behavior

Expected the same as in 0.55.1

Versions

  • Terragrunt version: 0.58.14
  • OpenTofu/Terraform version: v1.3.4
  • Environment details (Ubuntu 20.04, Windows 10, etc.): Ubuntu 20.04

yadamovych avatar Jun 05 '24 12:06 yadamovych

+1

dhanbdrkarki1 avatar Aug 04 '24 09:08 dhanbdrkarki1

@yadamovych Did you found solution to this issue?

dhanbdrkarki1 avatar Aug 09 '24 06:08 dhanbdrkarki1

@yadamovych Did you found solution to this issue?

No, still facing this issue.

yadamovych avatar Aug 13 '24 08:08 yadamovych

As a workaround, use version 0.55.1.

yadamovych avatar Aug 13 '24 08:08 yadamovych

@denis256, have you had the opportunity to examine the issue?

It appears that the "find_in_parent_folders" function is attempting to locate files from the inclusion location rather than from the execution folder as in the previous version of Terragrunt.

yadamovych avatar Aug 13 '24 08:08 yadamovych

@yadamovych version 0.55.1 didn't work for me.

dhanbdrkarki1 avatar Aug 15 '24 12:08 dhanbdrkarki1

Any news ?

But4ler avatar Oct 07 '24 15:10 But4ler

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.

github-actions[bot] avatar Feb 14 '25 02:02 github-actions[bot]

@denis256, have you had the opportunity to examine the issue?

It appears that the "find_in_parent_folders" function is attempting to locate files from the inclusion location rather than from the execution folder as in the previous version of Terragrunt.

Is this still actual for everyone? Will any type of fix be implemented in the upcoming releases?

Aleksandre1337 avatar May 27 '25 18:05 Aleksandre1337

Hey folks,

To my understanding, it's not a bug that find_in_parent_folders() resolves relative to the unit (where the configuration is included), rather than resolving relative to the include (where the included configuration is). It's intended behavior.

I understand that it can be frustrating to have to adjust configurations accordingly, but I don't see us adjusting this behavior in a future release unless there's good justification that it's improved behavior.

yhakbar avatar May 27 '25 19:05 yhakbar

Hey folks,

To my understanding, it's not a bug that find_in_parent_folders() resolves relative to the unit (where the configuration is included), rather than resolving relative to the include (where the included configuration is). It's intended behavior.

I understand that it can be frustrating to have to adjust configurations accordingly, but I don't see us adjusting this behavior in a future release unless there's good justification that it's improved behavior.

Hello, thank you for your prompt response.

Could you please clarify whether the find_in_parent_folder() function has always behaved this way, or if its behavior changed in a specific version?

Additionally, could you expand on your previous answer by providing a few simple examples?

Finally, what configuration adjustments would you recommend to better align with the behavior of the find_in_parent_folder() function?

Aleksandre1337 avatar May 27 '25 20:05 Aleksandre1337