Skip to main content
Knowledge Base

How do i merge two inputs from two hcl files (Unsupported block type; Blocks of type "import" are not expected here., and 1 other diagnostic(s)))

Answer

Hi there i'm trying to merge two inputs from two different HCL files, facing issue as (**Unsupported block type; Blocks of type "import" are not expected here., and 1 other diagnostic(s))** include "root" { path = find_in_parent_folders()} include "env" { path = "../env/terragrunt.hcl" expose = true } import "terra" { config_path = "../env/terragrunt.hcl"} inputs = merge ( import.terra.inputs, { security_groups = [ {} ] } )

Hi, will be helpful to format code with ` ``` ` for better visibility I think this code was influenced by `Imports` RFC, which has status "In development" https://terragrunt.gruntwork.io/docs/rfc/imports/#background However, inputs can be merged from multiple `import` blocks: ``` # a.hcl inputs = { value_a = "value from a" } # b.hcl inputs = { value_b = "value from b" } # terragrunt.hcl include "a" { path = "${get_terragrunt_dir()}/../a.hcl" expose = true } include "b" { path = "${get_terragrunt_dir()}/../b.hcl" expose = true } inputs = merge ( include.a.inputs, include.b.inputs, ) # tf file variable "value_a" {} variable "value_b" {} resource "local_file" "foo" { content = "${var.value_a}${var.value_b}" filename = "${path.module}/file.txt" } ```