Skip to content

[FEATURE] Support nested attributes in bundle inputs #2305

@cwe1ss

Description

@cwe1ss

Is your feature request related to a problem? Please describe.
We currently have many terraform modules with nested objects. E.g., for defining the network of an azure subscription, we have a terraform module with a variable like this:

variable "virtual_networks" {
  type = map(object({
    cidr_address   = string
    subnets        = map(object({
      cidr_address = string
    }))
  }))
}

This currently can't be mapped to bundle inputs, because it fails with the error terramate schema error: unrecognized "define" child block: [...] unexpected block type "attribute" in attribute "subnets", expected "prompt"

Describe the solution you'd like
Please allow nesting attribute-blocks within attribute-blocks to support nested type definitions.

input "virtual_networks" {
  type = map(object)
  attribute "cidr_address" { 
    type = string 
  }
  attribute "subnets" {
    type = map(object)
    attribute "cidr_address" {
      type = string
    }
  }
}

Describe alternatives you've considered

  • We thought about using separate bundles for each virtual network, however this would also create separate stacks for each virtual network, which we do not want in that case. We also have cases where we couldn't flatten the inputs enough, even with separate bundles.
  • We could use type = any, but then we lose the type system features (ability to generate a schema, terramate ui-integration, ...).

Additional context
Terramate version: v0.17.0-rc2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions