terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

Error when using `expose=true` on included module

Open tadejsv opened this issue 2 years ago • 6 comments

I have the following file tree:

terragrunt.hcl
_envcommon/
    server.hcl
modules/
    server/
        main.tf
staging/
    env.hcl
    vpc/
        terragrunt.hcl
    server/
        terragrunt.hcl

And here are the files

# staging/server/terragrunt.hcl
include "root" {
  path = find_in_parent_folders()
}

include "common" {
  path = "../../_envcommon/server.hcl"
}
# _envcommon/server.hcl

locals {
  _env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
  env_vars  = local._env_vars.locals
}

terraform {
  source = "../../modules//server"
}

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

inputs = {
  vpc_id            = dependency.vpc.outputs.vpc_id
  identifier        = "${local.env_vars.env_name}-server"
  name              = "${local.env_vars.env_name}"
}
# staging/env.hcl
locals {
  env_name    = "staging"
}

and root terragrunt.hcl just contains common backend/provider config.

Now, with this configuration everything works well. But when I modify staging/server/terragrunt.hcl like so (I want to use some locals from common env)

include "root" {
  path = find_in_parent_folders()
}

include "common" {
  path = "../../_envcommon/server.hcl"
+  expose = true
}

I get this error

ERRO[0000] Error reading file at path /home/tadej/projects/architecture/vpc: open /home/tadej/projects/architecture/vpc: no such file or directory 
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1

What am I doing wrong?

I am using terragrunt version v0.40.2

tadejsv avatar Nov 26 '22 11:11 tadejsv