0
0
Terraformcloud~5 mins

Block syntax and structure in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a block in Terraform?
A block is a container in Terraform configuration that groups related settings together, like resources, variables, or providers.
Click to reveal answer
beginner
Name the three main parts of a Terraform block.
1. Block type (like resource or variable)<br>2. Block label(s) (like resource name)<br>3. Block body (the settings inside curly braces {}).
Click to reveal answer
beginner
How do you write a resource block for an AWS S3 bucket named 'mybucket'?
resource "aws_s3_bucket" "mybucket" { bucket = "mybucket" acl = "private" }
Click to reveal answer
intermediate
What is the purpose of labels in a Terraform block?
Labels identify the block uniquely within its type, like naming a resource so Terraform can track it.
Click to reveal answer
intermediate
Can blocks be nested inside other blocks in Terraform? Give an example.
Yes, for example, a resource block can contain nested blocks like 'lifecycle' or 'provisioner' to add extra settings.
Click to reveal answer
What symbol encloses the body of a Terraform block?
A<>
B[]
C()
D{}
Which part of a Terraform block uniquely identifies a resource?
ABlock label
BBlock type
CBlock body
DBlock comment
Which of these is NOT a valid Terraform block type?
Afunction
Bresource
Cvariable
Dprovider
How many labels can a resource block have at minimum?
AOne
BTwo
CZero
DThree
What is the correct order of parts in a Terraform block?
ABlock body, block type, labels
BLabels, block type, block body
CBlock type, labels, block body
DLabels, block body, block type
Describe the structure of a Terraform block and explain the role of each part.
Think about how Terraform groups settings and identifies resources.
You got /4 concepts.
    Explain how nested blocks work in Terraform and give an example of when you might use one.
    Consider extra settings inside a resource.
    You got /3 concepts.