Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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 2. The resource type (like aws_instance) 3. The resource name (a unique label you choose) 4. The configuration inside curly braces defining properties
2. Which of the following is a valid property assignment inside a Terraform resource block?
easy
A. instance_type = t2.micro
B. instance_type => "t2.micro"
C. instance_type = "t2.micro"
D. instance_type: "t2.micro"
Solution
Step 1: Identify correct property syntax
Terraform uses = to assign values, and string values must be in quotes.
Step 2: Check each option
instance_type = "t2.micro" uses instance_type = "t2.micro", which is correct. instance_type = t2.micro misses quotes, B and C use invalid assignment symbols.
Final Answer:
instance_type = "t2.micro" -> Option C
Quick Check:
Property assignment uses = and quotes for strings [OK]
Hint: Use = and quotes for string values inside resource blocks [OK]
Common Mistakes:
Forgetting quotes around string values
Using colon or arrow instead of =
Missing equal sign
3. Given this resource block snippet, what will Terraform create?
5. You want to create two AWS EC2 instances with different names but the same AMI and instance type using resource blocks. Which is the best way to write this in Terraform?