terraform-provider-utils icon indicating copy to clipboard operation
terraform-provider-utils copied to clipboard

utils_deep_merge_* expose the object

Open sergiomcalzada opened this issue 2 years ago • 3 comments

Describe the Feature

After mergin the files you need to convert to an object the string. If you are chaining the merge a double encode is needed

Use Case

data "utils_deep_merge_json" "example" {
  for_each  = local.some_array
  input = [for s in each.value: jsonencode(s)]
}

resource "kubectl_manifest" "example" {    
  for_each  = data.utils_deep_merge_json.example
  yaml_body =  templatefile(**jsondecode(each.value.output).template**", merge(
                  **jsondecode(each.value.output).some_object**,
                  {
                    namespace = var.ns                    
                  },
                ))
}


Describe Ideal Solution

Expose the merged string as an object

sergiomcalzada avatar Jul 08 '22 06:07 sergiomcalzada

@sergiomcalzada thanks for mentioning this. Unfortunately, the Terraform Plugin framework we are using does not allow outputs of complex types (only primitive). Terraform has a newer framework which I think allows this, but we have not tested it yet.

aknysh avatar Jul 17 '22 15:07 aknysh

Any update on this? Maybe a planned date to test?

sergiomcalzada avatar Nov 02 '22 15:11 sergiomcalzada

@sergiomcalzada currently we don't have plans to switch to a new TF plugin framework for the provider - we have not tested it, it's relatively new, and will need time to switch the provider to use it, implement and test. We've discussed that, but no ETA on the implementation.

We do convert the objects returned from the provider to strings as well, then in terraform we convert them back to objects.

aknysh avatar Nov 02 '22 15:11 aknysh