Is your feature request related to a problem? Please describe.
Our modules often include variables with complex object({...} types. E.g., for configuring the network of a project, some attributes of that network variable are environment-specific (e.g. the cidr_range for the VNet), and others are the same for all environments (e.g., a peering_enabled-flag, which subnets to create, or the delegations of a subnet).
variable "network" {
type = object({
peering_enabled = bool
cidr_range = string
subnets = map(object({
cidr_range = string
delegations = optional(list(string), [])
}))
})
}
Describe the solution you'd like
Please use the same deep merge algorithm for resolving environment-inputs in bundle instances like you're using for resolving globals in a stack. This means, that objects/maps should be merged, and lists should be replaced.
This would allow us to configure a bundle instance like this:
apiVersion: terramate.io/cli/v1
kind: BundleInstance
spec:
source: /bundles/subscription
inputs:
# Settings that are the same for all environments
network:
peering_enabled: true
subnets:
containers:
delegations: ["Microsoft.App/environments"]
environments:
dev:
inputs:
network:
cidr_range: "192.168.1.0/24"
subnets:
containers:
cidr_range: "192.168.1.0/24"
prod:
inputs:
network:
cidr_range: "192.168.2.0/24"
subnets:
containers:
cidr_range: "192.168.2.0/24"
Describe alternatives you've considered
- Use flat inputs, but this doesn't work for maps and list of objects.
- Define every input for every
environments.{env}.inputs and don't set the inputs on spec.inputs, but this leaves very little usefulness to the environment-feature. we might as well just use separate bundle instances for each environment.
Additional context
Here's an example from my playground repo. the prod-environment should use the value from internet_allowed_fqdns defined in spec.inputs.network, but it does not, since the entire network input is overwritten.
Atmos also uses deep merging when resolving all the yaml-files for a component.
Is your feature request related to a problem? Please describe.
Our modules often include variables with complex
object({...}types. E.g., for configuring the network of a project, some attributes of thatnetworkvariable are environment-specific (e.g. thecidr_rangefor the VNet), and others are the same for all environments (e.g., apeering_enabled-flag, which subnets to create, or thedelegationsof a subnet).Describe the solution you'd like
Please use the same deep merge algorithm for resolving environment-inputs in bundle instances like you're using for resolving globals in a stack. This means, that objects/maps should be merged, and lists should be replaced.
This would allow us to configure a bundle instance like this:
Describe alternatives you've considered
environments.{env}.inputsand don't set the inputs onspec.inputs, but this leaves very little usefulness to the environment-feature. we might as well just use separate bundle instances for each environment.Additional context
Here's an example from my playground repo. the prod-environment should use the value from
internet_allowed_fqdnsdefined inspec.inputs.network, but it does not, since the entirenetworkinput is overwritten.Atmos also uses deep merging when resolving all the yaml-files for a component.