Skip to content

Find breaks on dependency processing when using relative working dir #4565

@pseudomorph

Description

@pseudomorph

Describe the bug

When running the find command with a relative --working-dir input, errors of the following sort occur:

Rel: can't make <X> relative to <Y>

Steps To Reproduce

Given the following structure:

deploy-1/terragrunt.hcl

terraform {
  source = "./"
}

include "foo" {
  path = "./foo.hcl"
}
deploy-2/terragrunt.hcl
terraform {
  source = "./"
}

include "foo" {
  path = "./foo.hcl"
}

dependency "dep1" {
  config_path = find_in_parent_folders("deploy-1")
}
❯ terragrunt find --working-dir ./deploy-2 --external --include --dependencies --json
10:00:03.949 ERROR  Rel: can't make ../deploy-1 relative to ./deploy-2
Rel: can't make ../deploy-1 relative to ./deploy-2
10:00:03.952 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

❯ terragrunt info print --working-dir deploy-2
10:10:40.583 INFO   [../deploy-1] Downloading Terraform configurations from ../deploy-1 into ../deploy-1/.terragrunt-cache/6DgLupwGqaPtxwqmvZ4LqpEViGE/MGhUjdUTxawhdEvKmRgih57sHes
{
  "config_path": "/Users/rossstrickland/repos/external/terragrunt/deploy-2/terragrunt.hcl",
  "download_dir": "/Users/rossstrickland/repos/external/terragrunt/deploy-2/.terragrunt-cache",
  "iam_role": "",
  "terraform_binary": "tofu",
  "terraform_command": "print",
  "working_dir": "deploy-2"
}

❯ cd deploy-2 
❯ terragrunt find --external --include --dependencies --json              
[
  {
    "type": "unit",
    "path": "../deploy-1",
    "include": {
      "foo": "foo.hcl"
    }
  },
  {
    "type": "unit",
    "path": ".",
    "include": {
      "foo": "foo.hcl"
    },
    "dependencies": [
      "../deploy-1"
    ]
  }
]

❯ terragrunt info print
10:09:46.969 INFO   [../deploy-1] Downloading Terraform configurations from ../deploy-1 into ../deploy-1/.terragrunt-cache/6DgLupwGqaPtxwqmvZ4LqpEViGE/MGhUjdUTxawhdEvKmRgih57sHes
{
  "config_path": "/Users/rossstrickland/repos/external/terragrunt/deploy-2/terragrunt.hcl",
  "download_dir": "/Users/rossstrickland/repos/external/terragrunt/deploy-2/.terragrunt-cache",
  "iam_role": "",
  "terraform_binary": "tofu",
  "terraform_command": "print",
  "working_dir": "/Users/rossstrickland/repos/external/terragrunt/deploy-2"
}

Expected behavior

find should produce consistent results between the two commands.

Nice to haves

  • Terminal output
  • Screenshots

Versions

  • Terragrunt version: 0.83.2
  • OpenTofu/Terraform version: N/A
  • Environment details (Ubuntu 20.04, Windows 10, etc.): N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions