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 type in Terraform?
A resource type in Terraform defines what kind of cloud or infrastructure object you want to create or manage, like a virtual machine, storage bucket, or network.
Click to reveal answer
beginner
How do you name a resource in Terraform?
You give a resource a unique name within its type to identify it in your configuration. This name is used to refer to the resource in other parts of your code.
Click to reveal answer
beginner
Example: What does this mean? resource "aws_instance" "web" {}
It means you are defining a resource of type 'aws_instance' (a virtual machine on AWS) and naming it 'web' so you can manage it in your Terraform code.
Click to reveal answer
intermediate
Why must resource names be unique within the same type?
Because Terraform uses the resource name to track and manage the resource. If names are duplicated, Terraform cannot tell which resource you mean.
Click to reveal answer
intermediate
Can resource types be from different providers in the same Terraform configuration?
Yes, Terraform supports multiple providers, so you can define resources from different cloud providers or services in one configuration.
Click to reveal answer
In Terraform, what does the resource type specify?
AThe output format
BThe name of the resource
CThe version of Terraform
DThe kind of infrastructure object to create
✗ Incorrect
The resource type tells Terraform what kind of object to create or manage, like a server or database.
What is the purpose of the resource name in Terraform?
ATo identify the resource uniquely within its type
BTo specify the cloud provider
CTo set the resource's IP address
DTo define the resource's size
✗ Incorrect
The resource name uniquely identifies the resource within its type so Terraform can manage it.
Which of these is a valid Terraform resource declaration?
Aresource aws_s3_bucket mybucket {}
Bresource "aws_s3_bucket" "mybucket" {}
Cresource "mybucket" "aws_s3_bucket" {}
Dresource "aws_s3_bucket" {}
✗ Incorrect
The correct syntax is resource "type" "name" {} with quotes around type and name.
Can you use the same resource name for two resources of the same type in Terraform?
ANo, names must be unique within the same type
BOnly if they are in different files
CYes, it is allowed
DOnly if they use different providers
✗ Incorrect
Resource names must be unique within the same type to avoid confusion.
Is it possible to define resources from multiple cloud providers in one Terraform file?
ANo, only one provider per file
BOnly if using modules
CYes, Terraform supports multiple providers
DOnly if providers are the same company
✗ Incorrect
Terraform allows multiple providers in one configuration to manage resources from different clouds.
Explain what resource types and resource names are in Terraform and why they are important.
Think about how Terraform knows what to create and how to track it.
You got /3 concepts.
Describe the correct syntax for declaring a resource in Terraform and what each part means.
Look at the example: resource "aws_instance" "web" {}
You got /4 concepts.
Practice
(1/5)
1. What does the resource block in Terraform define?
Terraform requires both resource type and name to be quoted strings.
Step 2: Identify the error
The resource name my_bucket is not quoted, causing a syntax error.
Final Answer:
Resource name is not quoted -> Option A
Quick Check:
Resource names must be quoted strings [OK]
Hint: Always quote resource names to avoid syntax errors [OK]
Common Mistakes:
Forgetting quotes around resource names
Assuming attributes cause errors
Thinking provider block is mandatory here
5. You want to create two AWS EC2 instances with different names but the same type in Terraform. Which is the best way to name the resources?
hard
A. resource "aws_instance" "aws_instance" {} and resource "aws_instance" "aws_instance" {}
B. resource "aws_instance" "app1" {} and resource "aws_instance" "app2" {}
C. resource "aws_instance" "1" {} and resource "aws_instance" "2" {}
D. resource "aws_instance" "instance" {} and resource "aws_instance" "instance" {}
Solution
Step 1: Understand resource naming rules
Resource names must be unique within the same type to avoid conflicts.
Step 2: Evaluate naming options
resource "aws_instance" "app1" {} and resource "aws_instance" "app2" {} uses unique, descriptive names app1 and app2. Choices that reuse the same name cause errors. The choice using numeric names is valid but less descriptive.
Final Answer:
resource "aws_instance" "app1" {} and resource "aws_instance" "app2" {} -> Option B
Quick Check:
Unique descriptive names prevent conflicts [OK]
Hint: Use unique, clear names for each resource [OK]