Giter VIP home page Giter VIP logo

Comments (9)

ben-dov avatar ben-dov commented on September 25, 2024 1

hey @levkohimins, I am usure if this is the correct thing to do, but I noticed changing config_path in b to "${get_terragrunt_dir()}/../a" seems to work in both c and d

from terragrunt.

flightlesstux avatar flightlesstux commented on September 25, 2024

I aggree! Same issue at my side at the same process.

Versions

  • Terragrunt version: 0.57.13
  • Terrafrom version: 1.8.2

from terragrunt.

levkohimins avatar levkohimins commented on September 25, 2024

Hey @ben-dov,
I wasn't able to repro the issue, the test config I used https://github.com/levkohimins/terragrunt-issue-3080. Can you confirm that the issue is resolved? If not, please provide test configs to reproduce it.

from terragrunt.

ben-dov avatar ben-dov commented on September 25, 2024

Hey @levkohimins, I tested and found what is missing in your repo to match my case (I probably was unclear).
in order to encounter my bug you just need to change the path in first/b/terragrunt.hcl from ../../second/a to ../a (use relative path of C to A).
after changing, you will see that plans running on C work fine, but plans on D have a warning (but otherwise seem to work).

from terragrunt.

levkohimins avatar levkohimins commented on September 25, 2024

Hey @ben-dov, Thanks for clarifying. I dare say, just the opposite, the previous behavior before v0.55.6 was incorrect. It makes sense and is intuitive when the relative path is calculated from the location of the included file, not from where it is included. In your case, you need to use the path_relative_to_include() function.

dependency "a" {
  config_path = "${path_relative_to_include()}/../a"
}

Please let me know if this doesn't solve your problem.

from terragrunt.

ben-dov avatar ben-dov commented on September 25, 2024

hey @levkohimins, if so, it is still weird that runnning C directly causes no warning,

Anyway, I attempted the change and it works in this simple scenario, but not it in others.

New example changes

  1. in b, hange config_path to ${path_relative_to_include()}/../a (as per your suggestion)
  2. Add the directory second under another parent named into_second
  3. Fix path in c, change include "b" path from ../../first/b/terragrunt.hcl to ../../../first/b/terragrunt.hcl

Expected behavior

Runing terragrunt plan in C or D works.

What actually happens

C returns an error:

ERRO[0000] <project-root>/into_second/into_second/second/a does not exist 
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1 

D also errors with:

WARN[0000] Error reading file <project-root>/into_second/into_second/second/a: open <project-root>/into_second/into_second/second/a: no such file or directory 
ERRO[0000] open <project-root>/into_second/into_second/second/a: no such file or directory 
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1 

from terragrunt.

levkohimins avatar levkohimins commented on September 25, 2024

hi @ben-dov,

I missed one point, since path_relative_to_include() returns a relative path from the b dir, config_path is assigned to ../../into_second/second/c/ + ../a, but including is happening from c directory and when we actually include the dependency a, we calculate the absolute path from the directory c and it looks like this
into_second/second/c/ + ../../into_second/second/c/ + ../a => into_second/into_second/second/a.

Thus, we have to build the relative path from the c directory, for this we need to use another func, path_relative_from_include(), and in the end it should look like this:

dependency "a" {
  config_path = "${path_relative_from_include()}/${path_relative_to_include()}/../a"
}

into_second/second/c/ + ../../../first/b/ + ../../into_second/second/c/ + ../a => into_second/second/a

I hope this helped you solve the issue.

from terragrunt.

ben-dov avatar ben-dov commented on September 25, 2024

THX @levkohimins for the quick response,

Running terragrunt plan on c works without issues,
but running on d prints the warning (but does not fail), kinda like the first problem:

WARN[0000] Error reading file <partial-absolute-path>/into_second/second/a: open <partial-absolute-path>/into_second/second/a: no such file or directory 
WARN[0000] Error reading partial config for dependency c: open <partial-absolute-path>/into_second/second/a: no such file or directory

what seems to be missing now is the parent the project directory in partial-absolute-path

I attempted to add another directory pre_into that will contain into_second, but the project directory was still missing from the path when running from d

from terragrunt.

levkohimins avatar levkohimins commented on September 25, 2024

hey @ben-dov

Running terragrunt plan on c works without issues, but running on d prints the warning (but does not fail), kinda like the first problem:

WARN[0000] Error reading file <partial-absolute-path>/into_second/second/a: open <partial-absolute-path>/into_second/second/a: no such file or directory 
WARN[0000] Error reading partial config for dependency c: open <partial-absolute-path>/into_second/second/a: no such file or directory

This is a bug. I will try to fix it in a while.

I am usure if this is the correct thing to do, but I noticed changing config_path in b to "${get_terragrunt_dir()}/../a" seems to work in both c and d.

It's great that you found a workaround.

from terragrunt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.