# Terraform Type Constraints (Collection & Structural)

### Type Constraints - Terraform Variables

* Type constraints control the type of variable values
* Primitive (Single type value)
  * number, string, bool
* Complex (Multiple types in a single variable)
  * list, tuple, map, object

### Complex types - Collections

* Collection types allow multiple values of one primitive types to be grouped together.
* Constructors of these Collections include:
  * list(type)
  * map(type)
  * set(type)

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2FHiwfhwfYG5sgXJfLCo73%2Fimage.png?alt=media&#x26;token=d2f7ed0c-0323-4987-8556-c5212c824f31" alt=""><figcaption></figcaption></figure>

### Complex types - Structural

* Structural types allow multiple values of different primitive types to be grouped together
* Constructors of these Collections include:
  * object(type)
  * tuple(type)
  * set(type)

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2FMtZDckuzgUz5ZytHlQRS%2Fimage.png?alt=media&#x26;token=9bdc2fa6-b6f2-4923-970a-b41db10e6b21" alt=""><figcaption></figcaption></figure>

### Dynamic types - The "any" constraint

* **Any** is a placeholder for primitive type yet to be decided
* Actual type will be determined at runtime

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2F2XhVM6FYwptiOKBTu7kq%2Fimage.png?alt=media&#x26;token=51a66e61-776b-4db6-ace6-52342f22b722" alt=""><figcaption></figcaption></figure>
