Skip to content

Commit 63fea15

Browse files
committed
Adding initial content for "Handling Data - Blocks" section (#418)
1 parent 4e2cbfd commit 63fea15

File tree

1 file changed

+24
-0
lines changed
  • website/docs/plugin/framework/handling-data

1 file changed

+24
-0
lines changed

website/docs/plugin/framework/handling-data/blocks.mdx

+24
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,27 @@ description: >-
55
---
66

77
# Blocks
8+
9+
A block is a container for other content:
10+
11+
```hcl
12+
resource "aws_instance" "example" {
13+
ami = "abc123"
14+
15+
network_interface {
16+
# ...
17+
}
18+
}
19+
```
20+
21+
A block has a type (resource in this example). Each block type defines how many labels must follow the type keyword. The resource block type expects two labels, which are aws_instance and example in the example above. A particular block type may have any number of required labels, or it may require none as with the nested network_interface block type.
22+
23+
After the block type keyword and any labels, the block body is delimited by the { and } characters. Within the block body, further arguments and blocks may be nested, creating a hierarchy of blocks and their associated arguments.
24+
25+
The Terraform language uses a limited number of top-level block types, which are blocks that can appear outside of any other block in a configuration file. Most of Terraform's features (including resources, input variables, output values, data sources, etc.) are implemented as top-level blocks.
26+
27+
## List, Set and Single Nested Blocks
28+
29+
Wherever possible, the usage of [nested attributes](/plugin/framework/handling-data/terraform-concepts#nested-attributes) is preferred.
30+
31+
The three options for [nested blocks](/plugin/framework/handling-data/terraform-concepts#nested-blocks) are `ListNestedBlock`, `SetNestedBlock` and `SingleNestedBlock`.

0 commit comments

Comments
 (0)