Attributes
Attributes are value storing fields in resource, data source, or provider schemas. Every attribute has an associated value type, which describes the kind of data the attribute can hold. Attributes also can describe value plan modifiers (resources only) and value validators in addition to those defined by the value type.
Available Attribute Types
Schemas support the following attribute types:
- Primitive: Attribute that contains a single value, such as a boolean, number, or string.
- Collection: Attribute that contains multiple values of a single element type, such as a list, map, or set.
- Nested: Attribute that defines a structure of explicit attibute names to attribute definitions, potentially with a wrapping collection type, such as a single structure of attributes or a list of structures of attributes.
- Object: Attribute that defines a structure of explicit attribute names to type-only definitions.
- Dynamic: Attribute that accepts any value type.
Primitive Attribute Types
Attribute types that contain a single data value, such as a boolean, number, or string.
Attribute 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 Attribute Types
Attribute types that contain multiple values of a single element type, such as a list, map, or set.
Attribute 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 |
Nested Attribute Types
Tip
Only supported when using protocol version 6.
Attribute types that define a structure of explicit attibute names to attribute definitions, potentially with a wrapping collection type, such as a single structure of attributes or a list of structures of attributes.
Attribute Type | Use Case |
---|---|
List Nested | Ordered collection of structures of attributes |
Map Nested | Mapping of arbitrary string keys to structures of attributes |
Set Nested | Unordered, unique collection of structures of attributes |
Single Nested | Single structure of attributes |
Object Attribute Type
Tip
Use nested attribute types where possible. Objects have limited capabilities.
Attribute type that defines a structure of explicit attribute names to type-only definitions.
Attribute Type | Use Case |
---|---|
Object | Single structure mapping explicit attribute names to type definitions |
Dynamic Attribute Type
Tip
Static attribute types should always be preferred over dynamic attribute types, when possible.
Developers dealing with dynamic attribute data will need to have extensive knowledge of the Terraform type system to properly handle all potential practitioner configuration scenarios.
Refer to Dynamic Data - Considerations for more information.
Attribute type that can be any value type, determined by Terraform or the provider at runtime.
Attribute Type | Use Case |
---|---|
Dynamic | Any value type of data, determined at runtime. |