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 the purpose of separating 'plan' and 'apply' stages in Terraform pipelines?
Separating 'plan' and 'apply' stages helps to review and approve infrastructure changes before they are made, reducing errors and improving control.
Click to reveal answer
beginner
In Terraform pipelines, what does the 'terraform plan' command do?
It creates an execution plan showing what changes Terraform will make to reach the desired state without applying them.
Click to reveal answer
intermediate
Why is it important to store the Terraform plan output and use it in the apply stage?
Storing the plan output ensures that the exact reviewed plan is applied, preventing unexpected changes during apply.
Click to reveal answer
intermediate
How can manual approval be integrated between plan and apply stages in a pipeline?
By adding a manual approval step after the plan stage, teams can review the plan output and confirm before applying changes.
Click to reveal answer
beginner
What is a common tool or service used to automate Terraform pipelines with plan and apply separation?
CI/CD tools like GitHub Actions, GitLab CI, or Jenkins are commonly used to automate Terraform pipelines with separate plan and apply stages.
Click to reveal answer
What does the 'terraform apply' command do?
AShows the planned changes without applying them
BValidates the Terraform configuration syntax only
CApplies the changes to reach the desired infrastructure state
DDeletes all infrastructure resources
✗ Incorrect
The 'terraform apply' command executes the planned changes to create, update, or delete infrastructure resources.
Why should the plan output be saved and reused in the apply stage?
ATo speed up the apply process
BTo automatically approve changes
CTo avoid running terraform init again
DTo ensure the exact reviewed plan is applied
✗ Incorrect
Saving the plan output ensures that the apply stage uses the exact plan reviewed, preventing unexpected changes.
What is a benefit of adding a manual approval step between plan and apply?
AIt allows review and prevents accidental changes
BIt speeds up deployment
CIt automatically fixes errors
DIt removes the need for version control
✗ Incorrect
Manual approval lets team members review planned changes before applying, reducing risk of mistakes.
Which command generates a Terraform execution plan?
Aterraform plan
Bterraform apply
Cterraform init
Dterraform validate
✗ Incorrect
'terraform plan' creates a preview of changes without applying them.
Which tool can be used to automate Terraform pipelines with plan and apply separation?
AMicrosoft Word
BGitHub Actions
CAdobe Photoshop
DSlack
✗ Incorrect
GitHub Actions is a CI/CD tool that can automate Terraform pipelines including separate plan and apply stages.
Explain why separating the 'plan' and 'apply' stages in Terraform pipelines is a best practice.
Think about how reviewing before doing helps avoid mistakes.
You got /4 concepts.
Describe how you would implement a pipeline that separates Terraform plan and apply stages with manual approval.
Consider the flow from planning to approval to applying.
You got /4 concepts.
Practice
(1/5)
1. What is the main benefit of separating terraform plan and terraform apply in pipelines?
easy
A. It speeds up the deployment by combining steps
B. It skips the need for state files
C. It automatically fixes errors during apply
D. It allows you to review changes before applying them
Solution
Step 1: Understand the purpose of terraform plan
This command shows what changes Terraform will make without applying them.
Step 2: Understand the purpose of terraform apply
This command applies the changes to the infrastructure based on the plan.
Final Answer:
It allows you to review changes before applying them -> Option D
Quick Check:
Plan shows changes first = B [OK]
Hint: Plan shows changes, apply makes them live [OK]
Common Mistakes:
Thinking plan applies changes
Believing apply skips state files
Assuming steps run faster combined
2. Which command correctly saves a Terraform plan to a file named myplan.tfplan?
easy
A. terraform apply -out=myplan.tfplan
B. terraform save myplan.tfplan
C. terraform plan -out=myplan.tfplan
D. terraform plan save myplan.tfplan
Solution
Step 1: Identify the correct syntax for saving a plan
The correct command uses terraform plan -out=filename to save the plan.
Step 2: Check each option
terraform plan -out=myplan.tfplan matches the correct syntax exactly.
Final Answer:
terraform plan -out=myplan.tfplan -> Option C
Quick Check:
Plan with -out saves file = C [OK]
Hint: Use 'plan -out=' to save plans, not apply [OK]
Common Mistakes:
Using apply instead of plan to save
Using incorrect command like 'save'
Missing the '-out=' flag
3. Given these commands run in order: terraform plan -out=planfile terraform apply planfile What happens when you run terraform apply planfile?
medium
A. Terraform applies exactly the changes saved in planfile
B. Terraform ignores planfile and creates a new plan
C. Terraform applies changes but may differ from planfile
D. Terraform throws an error because planfile is not a valid command
Solution
Step 1: Understand the role of the saved plan file
The plan file contains the exact changes Terraform will apply.
Step 2: Understand how terraform apply planfile works
This command applies the saved plan exactly, without recalculating changes.
Final Answer:
Terraform applies exactly the changes saved in planfile -> Option A
Quick Check:
Apply saved plan = exact changes [OK]
Hint: Apply with plan file applies exact saved changes [OK]
Common Mistakes:
Thinking apply recalculates plan
Assuming apply ignores plan file
Believing apply with plan file causes errors
4. You run terraform apply myplan.tfplan but get an error saying the plan file is invalid. What is the most likely cause?
medium
A. You forgot to run terraform init before apply
B. The plan file was created with a different Terraform version
C. You used terraform plan without -out flag
D. The plan file is empty because no changes were detected
Solution
Step 1: Identify compatibility issues with plan files
Plan files are version-specific and may be invalid if Terraform versions differ.
Step 2: Check other options
Running init is required but usually causes different errors; missing -out means no plan file saved; empty plan files do not cause invalid file errors.
Final Answer:
The plan file was created with a different Terraform version -> Option B
Quick Check:
Version mismatch causes invalid plan file error [OK]
Hint: Check Terraform versions match when using saved plans [OK]
Common Mistakes:
Assuming missing init causes invalid plan file error
Thinking empty plan files cause invalid file errors
Confusing missing -out with invalid plan file
5. You want to implement a pipeline that separates planning and applying Terraform changes. Which sequence of commands ensures you can review the plan before applying exactly those changes?
hard
A. terraform plan -out=planfile && terraform apply planfile
B. terraform apply && terraform plan -out=planfile
C. terraform plan && terraform apply
D. terraform apply -out=planfile && terraform apply planfile
Solution
Step 1: Identify correct order for plan and apply separation
First, run terraform plan -out=planfile to save the plan and review it.
Step 2: Apply the saved plan exactly
Then, run terraform apply planfile to apply the reviewed changes exactly.
Final Answer:
terraform plan -out=planfile && terraform apply planfile -> Option A
Quick Check:
Plan with -out then apply saved plan = A [OK]
Hint: Plan with -out then apply saved plan file [OK]