0
0
Terraformcloud~10 mins

Code review for infrastructure changes in Terraform - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Code review for infrastructure changes
Developer writes Terraform code
Developer runs 'terraform plan'
Reviewers examine plan output
Reviewers provide feedback
Approve changes
Developer applies
Shows the flow from writing code, planning changes, reviewing, and either approving or requesting updates before applying.
Execution Sample
Terraform
terraform plan
# Shows proposed infrastructure changes
# Reviewers check for errors or risks
terraform apply
# Applies approved changes
This simulates the process of planning and applying infrastructure changes with review steps.
Process Table
StepActionInput/ConditionOutput/ResultNext Step
1Developer writes Terraform codeNew feature or fix neededTerraform code readyRun 'terraform plan'
2Run 'terraform plan'Terraform codePlan output showing changesReview plan output
3Review plan outputPlan outputFeedback: Approve or Request changesIf approve -> apply; else -> update code
4If changes requestedFeedback to developerDeveloper updates codeBack to step 2
5If approvedApproval givenRun 'terraform apply'Apply changes
6Run 'terraform apply'Approved planInfrastructure updatedEnd
7EndInfrastructure updatedProcess completeNone
💡 Process ends after infrastructure is updated successfully.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
Terraform CodeNoneWrittenUnchangedMay be updatedUpdated if requestedFinal versionApplied
Plan OutputNoneNoneGeneratedReviewedRegenerated if updatedFinal approvedNone
Review FeedbackNoneNoneNoneApprove or RequestMay changeApprovedNone
Infrastructure StateCurrentCurrentCurrentCurrentCurrentUpdatedUpdated
Key Moments - 3 Insights
Why do we run 'terraform plan' before applying changes?
Because 'terraform plan' shows what changes will happen without making them, so reviewers can check for mistakes or risks before anything is applied. See execution_table step 2 and 3.
What happens if reviewers request changes after seeing the plan?
The developer updates the Terraform code and runs 'terraform plan' again to generate a new plan for review. This loop continues until approval. See execution_table steps 3 and 4.
Can we apply changes without review?
Best practice is to always review the plan output before applying to avoid unintended changes. Skipping review risks errors. See execution_table step 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output after running 'terraform plan'?
APlan output showing changes
BTerraform code ready
CInfrastructure updated
DFeedback: Approve or Request changes
💡 Hint
Check execution_table row with Action 'Run terraform plan' (Step 2) for output.
At which step does the developer update the Terraform code after feedback?
AStep 2
BStep 4
CStep 3
DStep 5
💡 Hint
Look for the step where 'Developer updates code' happens in execution_table.
If the developer skips review and applies changes immediately, which step is missed?
AStep 5
BStep 2
CStep 3
DStep 6
💡 Hint
Review happens at 'Review plan output' step in execution_table.
Concept Snapshot
Code review for infrastructure changes:
1. Write Terraform code.
2. Run 'terraform plan' to see proposed changes.
3. Review plan output carefully.
4. Provide feedback: approve or request changes.
5. Apply changes only after approval.
This prevents errors and ensures safe updates.
Full Transcript
This visual execution shows how infrastructure changes are managed with Terraform code review. First, the developer writes code and runs 'terraform plan' to generate a preview of changes. Reviewers then examine this plan to catch errors or risks. They either approve or request changes. If changes are requested, the developer updates the code and repeats the plan and review steps. Once approved, the developer runs 'terraform apply' to update the infrastructure. This process ensures safe, controlled infrastructure updates.