kbst / terraform-kubestack

Kubestack is a framework for Kubernetes platform engineering teams to define the entire cloud native stack in one Terraform code base and continuously evolve the platform safely through GitOps.
https://www.kubestack.com
Apache License 2.0
651 stars 92 forks source link

feat: add a passthrough map to configuration #338

Open jeacott1 opened 3 months ago

jeacott1 commented 3 months ago

It would be helpful for downstream configuration if kubestack users could include arbitrary per environment configuration in the standard structure that was passed through to the output.

ie: given the usual

configuration = {
    apps = {
       #add a map where users can just pass through whatever they like.
       custom = {
          ENV_mycustomconfig = ""
          DISK_size = 500
       }
    }

This could be exported as its own map(map(string/any/?)) and subsequently used in arbitrary foreach blocks instead of having to duplicate the configuration/apps/ops/whatever to add custom bits and pieces. I suggest a separate export here just because 3 levels of map usually gets awkward in tf.

thoughts?

pst commented 3 months ago

I'm not quite sure what this is supposed to do or be used for. The configuration var is of type map any. Why isn't what you are trying to do working?

jeacott1 commented 3 months ago

@pst true, but the setunion won't copy nested maps.

pst commented 3 months ago

I can't follow. I suggest you take a look at the code. https://github.com/kbst/terraform-kubestack/blob/master/common/configuration/outputs.tf

jeacott1 commented 3 months ago

@pst you are right, it will include the map I wanted, but any overrides in other environments will completely replace instead of amending the map. I guess thinking about it, what I am really asking for here is a special cased variable that would not be a blanket replace in ops/dev etc, where the default map values are preserved unless overridden. It would just be a nice to have option I think. It would help if tf had better support for deep merge but for now at least it doesn't.

pst commented 2 months ago

Are you planning to send a PR to support merging of nested maps?