Provider Schema Types Map of Maps

Hi @skylerto,

From the perspective of the Terraform type system, an arbitrarily-nested map structure is really an object type describing the specific set of attributes and their individual types. The type system does not have the concept of “map of a mixture of types” because Terraform needs to track type information for expression validation.

However, when talking about type constraints rather than particular types there is the idea of the any constraint which is a placeholder for a single type chosen dynamically at runtime. In variables we can already use this in Terraform 0.12 as I think you’ve seen:

variable "example" {
  type = any
}

These can then be validated using custom validation rules (experimental at the time of writing) to apply more complex validation rules than the type system can allow.

Terraform itself also allows attributes associated with resources in providers to be defined as using this any constraint, which in the internals of Terraform is called the “dynamic pseudo-type”. However, as you’ve seen the current SDK does not expose that capability because it’s trying to retain compatibility with Terraform 0.11 at the moment.

Once the SDK does support an any constraint, that would be the way to achieve the result you need here, possibly along with some custom validation rules written in Go that would be the provider-space analog to the variable validation rules feature I mentioned above.

The SDK team is tracking this particular feature in this issue:

1 Like