gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.1k stars 984 forks source link

hclvalidate didn't works on hcl that contains dependency #3587

Open kamontat opened 1 day ago

kamontat commented 1 day ago

Describe the bug

When I try to run hclvalidate command on terragrunt.hcl that contains dependency, I got dependency.namespace is object with 1 attribute "inputs".

CleanShot 2024-11-21 at 23 49 01

When I try to run hclvalidate command with --terragrunt-hclvalidate-show-config-path, I got json: cannot unmarshal string into Go struct field CtyJSONOutput.Value of type map[string]interface {}.

CleanShot 2024-11-21 at 23 50 53

Steps To Reproduce

Create terragrunt.hcl with dependency field, and run hclvalidate on that directory.

dependency "namespace" {
  config_path = "${get_terragrunt_dir()}/../namespace"
}
inputs = {
  namespace = dependency.namespace.outputs.namespace
}

Expected behavior

Similar result as run tofu validate.

Nice to haves

Versions

yhakbar commented 8 hours ago

Hey @kamontat ,

Does that dependency have any outputs? Has it been applied yet?

If not, you may need to mock those outputs so that the relevant cty values are available for HCL parsing at this phase.

Let me know if any of that doesn't make sense!