0
0
Terraformcloud~5 mins

Resource block syntax in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a resource block in Terraform?
A resource block defines a piece of infrastructure to create or manage, like a server or database. It tells Terraform what to build and how.
Click to reveal answer
beginner
What are the four main parts of a Terraform resource block?
1. The keyword resource<br>2. The resource type (like aws_instance)<br>3. The resource name (a unique label you choose)<br>4. The configuration inside curly braces defining properties
Click to reveal answer
beginner
Example:
resource "aws_instance" "web" {<br>  ami = "ami-123456"<br>  instance_type = "t2.micro"<br>}
What does this block do?
It tells Terraform to create an AWS server named "web" using the AMI with ID "ami-123456" and the instance type "t2.micro".
Click to reveal answer
beginner
Can you have multiple resource blocks of the same type in one Terraform file?
Yes! Each resource block must have a unique name within its type, so you can create many resources of the same type by giving each a different name.
Click to reveal answer
beginner
Why is it important to use meaningful names in resource blocks?
Meaningful names help you and others understand what each resource is for, making your infrastructure easier to manage and avoid confusion.
Click to reveal answer
What keyword starts a resource block in Terraform?
Aprovider
Bvariable
Cmodule
Dresource
In resource "aws_s3_bucket" "mybucket" {}, what is "mybucket"?
AResource type
BResource name
CProvider name
DVariable name
Which part of a resource block defines the cloud service or infrastructure type?
AProvider block
BResource name
CResource type
DOutput block
Can two resource blocks have the same resource name in the same Terraform file?
AOnly if they are different types
BYes, always
CNo, names must be unique
DOnly if they are in different folders
What symbol encloses the configuration settings inside a resource block?
ACurly braces {}
BSquare brackets []
CAngle brackets <>
DParentheses ()
Describe the structure of a Terraform resource block and its main components.
Think about how you tell Terraform what to create and how.
You got /4 concepts.
    Explain why unique and meaningful resource names are important in Terraform configurations.
    Imagine managing many servers with confusing labels.
    You got /3 concepts.