»Blocks
The Terraform language uses a block as a container for other attributes and blocks. Terraform implements many top level blocks, such as provider
and resource
, while providers can implement nested blocks in their schema to enable practitioners to configure data.
Use nested attributes for new schema implementations. Block support is mainly for migrating prior SDK-based providers.
In this example, the Terraform-defined resource
block contains a provider-defined ami
attribute and network_interface
block.
The configuration syntax for a provider-defined block is a type (block name) and the body is delimited by the {
and }
characters. Each block has an associated nesting mode, which declares whether a block is repeatable. The available nesting modes are:
- List: Ordered collection of objects
- Set: Unordered collection of objects
- Single: One object
For list and set blocks, configurations can implement dynamic
block expressions to reduce hardcoded block values.
Terraform Configuration
Use the following syntax in Terraform configuration for nested blocks:
Schema
Define nested blocks in the schema as follows: