Terragrunt generated dependency input become string

I’m having a hard time figuring out how to using list output in another module as a dependency.

I do working with Terragrunt v0.23.17, Terraform v0.12.24

In module output variable code is like

variable “public_lb_a_b” {
type =list
default = [
“subnet-a”,
“subnet-b”
]
}

output “public_lb_a_b” {
value = var.public_lb_a_b
description = “A_B”
}

I want to use the output as a dependency, code is like terragrunt.hcl

dependency “vpc” {
config_path = “…/vpc”
}

public_lb_a_b = dependency.vpc.outputs.public_lb_a_b

When I do apply (terragrunt apply )

the variable outputs warped with jsonencode

  • subnets = [
    + jsonencode(
    [
    + “subnet-d7e6c3a1”,
    + “subnet-baa090de”,
    ]
    ),
    ]

My expectation is

  • subnets = [
    + “subnet-d7e6c3a1”,
    + “subnet-baa090de”,
    ]

So I end up with an error The subnet ID ‘[“subnet-a”,“subnet-b”]’ is not valid. What I’m missing here?

solved with dirty way

subnets = split(",", replace(tostring("${var.public_lb_a_b}"), “/[”\][]/" ,"" ))

Apologies for the delay in getting back to you on this!

After taking a look, I believe we need a bit more context on this to see what might be going on. I just tried this with the following minimal example and was not able to reproduce the behavior you are seeing:

directory structure

.
├── dep
│   ├── main.tf
│   └── terragrunt.hcl
└── main
    ├── main.tf
    └── terragrunt.hcl

dep/main.tf

variable "foo" {
  type = list(string)
  default = [
    "subnet-a",
    "subnet-b"
  ]
}

output "foo" {
  value = var.foo
}

(dep/terragrunt.hcl is an empty file)

main/main.tf

variable "subnets" {
  type = list(string)
}

output "bar" {
  value = var.subnets
}

main/terragrunt.hcl

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

inputs = {
  subnets = dependency.dep.outputs.foo
}