DELAPARRA
Index
Color
NL
Category: Terraform

block

Explained by Updated

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.

Definition source Coders Lingo, CC BY 4.0

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

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with B

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.