0
0
Terraformcloud~10 mins

Terraform plan for preview - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Terraform plan for preview
Write Terraform config
Run 'terraform init'
Run 'terraform plan'
Terraform reads current state
Terraform compares desired vs current
Show planned changes
User reviews plan
Decide to apply or modify config
Terraform plan reads your config and current state, then shows what changes it will make without applying them.
Execution Sample
Terraform
terraform init
terraform plan
Initialize Terraform and preview the infrastructure changes without applying them.
Process Table
StepActionEvaluationResult
1Run 'terraform init'Initialize backend and providersBackend and providers ready
2Run 'terraform plan'Read current stateCurrent state loaded
3Compare desired config with current stateDetect differencesPlan created with changes
4Show plan outputDisplay actions (add, change, destroy)User sees what will happen
5User reviews planDecide next stepPlan accepted or config changed
6ExitNo changes applied yetPreview complete
💡 Plan shows changes but does not apply them; user must run 'terraform apply' to make changes.
Status Tracker
VariableStartAfter initAfter planFinal
terraform stateemptyinitializedloaded current stateunchanged (preview only)
plan outputnonenonegenerated with changesdisplayed to user
Key Moments - 3 Insights
Why does 'terraform plan' not change any real infrastructure?
'terraform plan' only shows what would happen; it reads state and config but does not apply changes, as shown in execution_table step 6.
What does Terraform compare during 'plan'?
It compares the desired config with the current state to find differences, as seen in execution_table step 3.
Why must we run 'terraform init' before 'terraform plan'?
'terraform init' sets up providers and backend needed to read state and config, enabling 'plan' to work correctly (execution_table step 1).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the result after running 'terraform init'?
ABackend and providers ready
BPlan created with changes
CCurrent state loaded
DNo changes applied yet
💡 Hint
Check execution_table row 1 under Result column.
At which step does Terraform compare desired config with current state?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look at execution_table rows and find where comparison happens.
If you skip 'terraform init', what will likely happen when running 'terraform plan'?
APlan will show changes correctly
BPlan will apply changes automatically
CPlan will fail due to missing backend/providers
DPlan will ignore current state
💡 Hint
Refer to key_moments about why 'terraform init' is needed before 'plan'.
Concept Snapshot
terraform init: prepares backend and providers
terraform plan: previews changes without applying
Reads current state and compares with config
Shows add/change/destroy actions
No real changes until 'terraform apply' runs
Full Transcript
Terraform plan is a command that lets you see what changes Terraform will make to your cloud infrastructure before actually making them. First, you run 'terraform init' to set up the environment. Then, 'terraform plan' reads the current state and compares it with your desired configuration. It shows a list of changes it will perform, like adding or removing resources. This preview helps you avoid surprises. No real changes happen until you run 'terraform apply'.