block
What is block?
block: The fundamental HCL container: a type, optional labels, and a body in braces. resource, variable, module are all blocks. A block is the basic building unit of Terraform's configuration language, HCL. It has a type, optional labels, and a body in curly braces. resource "aws_s3_bucket" "assets" { ... } is a block of type resource with two labels.
Frequently asked questions about block
How is block used in practice?
Everything in a Terraform project is made of blocks: provider, variable, output, module and resource. Blocks can also be nested, such as a lifecycle block inside a resource.
What should you keep in mind with block?
Once you see this pattern, Terraform files become much easier to read. Each block declares one thing and its settings. Keep related blocks in sensibly named files, such as network.tf and database.tf, and run terraform fmt so the layout stays consistent across the team. Terraform reads all files in a folder together, so the split is purely for people.
What does an example of block look like?
block_type "label_one" "label_two" { argument = value } At a glance
| Category | Terraform |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |