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 does the terraform plan command do?
It shows a preview of the changes Terraform will make to your infrastructure without applying them. It helps you understand what will be created, changed, or destroyed.
Click to reveal answer
beginner
Why is it important to run terraform plan before terraform apply?
Running terraform plan helps catch mistakes early by showing what changes will happen. This prevents unexpected or harmful changes to your infrastructure.
Click to reveal answer
beginner
What does it mean if terraform plan shows no changes?
It means your current infrastructure matches the configuration files exactly, so no updates, creations, or deletions are needed.
Click to reveal answer
intermediate
How can you save the output of terraform plan for later use?
You can save the plan to a file using terraform plan -out=planfile. Later, you can apply this exact plan with terraform apply planfile.
Click to reveal answer
beginner
What is the difference between terraform plan and terraform apply?
terraform plan previews changes without making them. terraform apply actually makes the changes to your infrastructure.
Click to reveal answer
What does terraform plan primarily do?
AInitializes Terraform configuration
BShows a preview of infrastructure changes
CDeletes all resources
DApplies changes to infrastructure
✗ Incorrect
terraform plan previews changes without applying them.
How do you save a Terraform plan to a file?
Aterraform plan -out=planfile
Bterraform plan -save=planfile
Cterraform save planfile
Dterraform apply -plan=planfile
✗ Incorrect
Use terraform plan -out=planfile to save the plan.
If terraform plan shows no changes, what does it mean?
ATerraform will destroy all resources
BTerraform configuration has errors
CYour infrastructure matches the configuration
DTerraform will create new resources
✗ Incorrect
No changes means infrastructure matches the config.
Which command actually makes changes to your infrastructure?
Aterraform apply
Bterraform init
Cterraform plan
Dterraform validate
✗ Incorrect
terraform apply applies the planned changes.
Why should you run terraform plan before terraform apply?
ATo backup your infrastructure
BTo delete resources
CTo initialize Terraform
DTo preview changes and avoid mistakes
✗ Incorrect
Planning helps catch mistakes before applying changes.
Explain the purpose and benefits of using terraform plan in your workflow.
Think about how seeing changes before applying helps you.
You got /4 concepts.
Describe the difference between terraform plan and terraform apply.
One shows what will happen, the other makes it happen.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the terraform plan command?
easy
A. To destroy all existing infrastructure
B. To apply changes directly to cloud resources
C. To initialize the Terraform working directory
D. To preview changes Terraform will make without applying them
Solution
Step 1: Understand the role of terraform plan
This command shows what changes Terraform will make but does not apply them.
Step 2: Compare with other commands
terraform apply applies changes, terraform destroy removes resources, and terraform init initializes the directory.
Final Answer:
To preview changes Terraform will make without applying them -> Option D
Quick Check:
Preview changes = terraform plan [OK]
Hint: Plan previews changes, apply makes changes [OK]
Common Mistakes:
Confusing plan with apply
Thinking plan modifies resources
Mixing plan with init or destroy
2. Which of the following is the correct syntax to run a Terraform plan with a specific variable file named vars.tfvars?
easy
A. terraform plan --vars-file=vars.tfvars
B. terraform plan --varfile vars.tfvars
C. terraform plan -var-file=vars.tfvars
D. terraform plan -varfile=vars.tfvars
Solution
Step 1: Recall correct flag for variable files
The correct flag is -var-file with a hyphen between var and file.
Step 2: Check syntax correctness
terraform plan -var-file=vars.tfvars uses -var-file=vars.tfvars, which is the official syntax. Other options use incorrect flags.
Final Answer:
terraform plan -var-file=vars.tfvars -> Option C
Quick Check:
Use -var-file=filename for variable files [OK]
Hint: Use -var-file=filename to specify variable files [OK]
Common Mistakes:
Using --varfile instead of -var-file
Mixing underscores or missing hyphens
Using --vars-file which is invalid
3. Given this Terraform plan output snippet:
# aws_instance.example will be created
+ resource "aws_instance" "example" {
+ ami = "ami-123456"
+ instance_type = "t2.micro"
}
What does the plus sign (+) before the resource indicate?
medium
A. The resource will be created
B. The resource will be destroyed
C. The resource will be updated in place
D. The resource is unchanged
Solution
Step 1: Understand Terraform plan symbols
The plus sign (+) means Terraform plans to add or create the resource.
Step 2: Differentiate from other symbols
Minus (-) means destroy, ~ means update, no symbol means unchanged.
Final Answer:
The resource will be created -> Option A
Quick Check:
Plus sign (+) = create resource [OK]
Hint: Plus (+) means create, minus (-) means destroy [OK]
Common Mistakes:
Confusing + with update or destroy
Ignoring symbols and guessing
Assuming no symbol means create
4. You run terraform plan but get this error:
Error: No configuration files found!
What is the most likely cause?
medium
A. You ran the command outside the Terraform configuration directory
B. You forgot to run terraform init first
C. Your Terraform version is outdated
D. Your cloud provider credentials are missing
Solution
Step 1: Analyze the error message
The error says no configuration files found, meaning Terraform can't find .tf files.
Step 2: Identify common causes
This usually happens if you run the command outside the folder containing Terraform files.
Final Answer:
You ran the command outside the Terraform configuration directory -> Option A
Quick Check:
No config files = wrong directory [OK]
Hint: Run plan inside folder with .tf files [OK]
Common Mistakes:
Assuming init fixes missing files
Blaming credentials for config file errors
Ignoring current working directory
5. You want to preview changes only for a specific resource named aws_s3_bucket.mybucket without affecting others. Which command achieves this?
hard
A. terraform plan -only=aws_s3_bucket.mybucket
B. terraform plan -target=aws_s3_bucket.mybucket
C. terraform plan --filter=aws_s3_bucket.mybucket
D. terraform plan -resource=aws_s3_bucket.mybucket
Solution
Step 1: Recall how to target specific resources in plan
The -target flag limits the plan to specified resources.
Step 2: Verify correct flag usage
terraform plan -target=aws_s3_bucket.mybucket uses -target=aws_s3_bucket.mybucket, which is the correct syntax. Other options are invalid flags.
Final Answer:
terraform plan -target=aws_s3_bucket.mybucket -> Option B
Quick Check:
Use -target to preview specific resources [OK]
Hint: Use -target=resource_name to limit plan scope [OK]