Skip to content

dependency block with a relative path does not resolve anymore when included with expose=true #3475

@JeanFred

Description

@JeanFred

Describe the bug

If a dependency block with a relative path is present in a file that is included, the path resolution stops working when that file is included with expose=true.

Steps To Reproduce

I have a repo which follows the _envcommon pattern described in the live-example − here is a reconstructed, minimal reproduction:

.
├── environments
│   ├── _envcommon
│   │   └── b.hcl
│   ├── qc
│   │   └── eu-west-1
│   │       ├── a
│   │       │   └── terragrunt.hcl
│   │       └── b
│   │           └── terragrunt.hcl
│   └── terragrunt.hcl
└── layers
      ├── a
      │   └── main.tf
      └── b
          └── main.tf

b.hcl

terraform {
  source = "${dirname(find_in_parent_folders())}/..//layers/b"
}

dependency "a" {
  config_path = "../a/"
}

inputs = {
  region = dependency.a.outputs.region
}

qc/eu-west-1/a/terragrunt.hcl

include "root" {
  path = find_in_parent_folders()
}

terraform {
  source = "${dirname(find_in_parent_folders())}/..//layers/a"
}

qc/eu-west-1/b/terragrunt.hcl

include "root" {
  path = find_in_parent_folders()
}

include "envcommon" {
  path   = "${dirname(find_in_parent_folders())}/_envcommon/b.hcl"
  expose = true
}

When expose=true is commented out, all is fine − a Terraform plans runs successfully, and the output from a is passed to b

With expose=true, the plan fails with
On latest Terragrunt 0.68.1:

21:06:42.299 ERROR  stat ../../../a: no such file or directory
21:06:42.299 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

on Terragrunt 0.60.1

level=warning msg=Error reading file terraform-test/environments/a: open terraform-test/environments/a: no such file or directory
level=error msg=open terraform-test/environments/a: no such file or directory
level=error msg=Unable to determine underlying exit code, so Terragrunt will exit with error code 1

Expected behavior

The dependency keeps working even after using expose=true − or it never works! But it behaves consistently.

Versions

  • Terragrunt version: 0.60.1 ; also retested with latest 0.68.1
  • OpenTofu/Terraform version: 1.7.5
  • Environment details: Ubuntu 20.04

Additional context

I guess I will try using some combination of path_relative_to_include, path_relative_from_include, get_terragrunt_dir and friends until it works :)

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