Types
Types are value storage and access mechanism for resource, data source, or provider schema data. Every attribute and block has an associated type, which describes the kind of data. These types fully support Terraform's type system concepts that cannot be represented in Go built-in types, such as *string
. Framework types can be extended by implementing custom types in provider code or shared libraries to provide specific use case functionality.
Available Types
The framework type system supports the following types:
- Primitive: Type that contains a single value, such as a boolean, number, or string.
- Collection: Type that contains multiple values of a single element type, such as a list, map, or set.
- Object: Type that defines a mapping of explicit attribute names to value types.
- Tuple: Type that defines an ordered collection of elements where each element has it's own type.
- Dynamic: Container type that can contain any underlying value type.
Primitive Types
Types that contain a single data value, such as a boolean, number, or string. These are directly associated with their primitive attribute type.
Type | Use Case |
---|---|
Bool | Boolean true or false |
Float32 | 32-bit floating point number |
Float64 | 64-bit floating point number |
Int32 | 32-bit integer number |
Int64 | 64-bit integer number |
Number | Arbitrary precision (generally over 64-bit, up to 512-bit) number |
String | Collection of UTF-8 encoded characters |
Collection Types
Types that contain multiple values of a single element type, such as a list, map, or set.
These types are associated with:
- Collection attribute types
- Collection-based nested attribute type (list, map, and set of object type)
- Collection-based nested block type (list and set of object type)
Type | Use Case |
---|---|
List | Ordered collection of single element type |
Map | Mapping of arbitrary string keys to values of single element type |
Set | Unordered, unique collection of single element type |
Object Type
Type that defines a mapping of explicit attribute names to value types.
This type is associated with:
- Single nested attibute type
- Single nested block type
- Nested object within collection-based nested attribute type (list, map, and set of object type)
- Nested object within collection-based nested block type (list and set of object type)
- Object attribute type
Type | Use Case |
---|---|
Object | Mapping of explicit attribute names to values |
Tuple Type
Type that defines an ordered collection of elements where each element has it's own type.
Note
This type intentionally includes less functionality than other types in the type system as it has limited real world application and therefore is not exposed to provider developers except when working with dynamic values.
Type | Use Case |
---|---|
Tuple | Ordered collection of multiple element types |
Dynamic Type
Container type that can contain any underlying value type, determined by Terraform or the provider at runtime.
Type | Use Case |
---|---|
Dynamic | Any value type of data, determined at runtime. |