Sample questions
Terraform Plan Apply Drift ImportDifficulty 1
When you run terraform plan, what does Terraform actually do?
- aIt immediately creates, updates, or destroys the resources described in the configuration
- bIt compares the configuration and refreshed state against real infrastructure and prints a proposed plan✓
- cIt only checks the configuration files for syntax errors and never looks at state
- dIt deletes the state file and rebuilds it from scratch based on the configuration
Explanation:terraform plan is a read-only, dry-run step: it refreshes state against real infrastructure, compares that to the configuration, and prints the proposed create/update/destroy actions. It never applies changes by itself.
Terraform Plan Apply Drift ImportDifficulty 1
By default, when you run terraform apply interactively without any flags, what does Terraform require before making any changes?
- aNothing — it applies the plan immediately without any prompt
- bA separate
terraform plan -out file must already exist on disk, or apply refuses to run - cIt shows the plan and waits for you to type 'yes' at a confirmation prompt✓
- dIt requires a signed commit in version control before it will proceed
Explanation:Run interactively without -auto-approve or a saved plan file, terraform apply computes and displays the plan, then pauses for an explicit 'yes' confirmation before touching any infrastructure.
Terraform Plan Apply Drift ImportDifficulty 1
What does the terraform import command do?
- aIt associates an already-existing real infrastructure resource with a resource address in Terraform state✓
- bIt creates a brand-new resource in the cloud provider and simultaneously writes matching configuration for it
- cIt exports the current Terraform state as a downloadable configuration file
- dIt copies resources from one cloud provider account to another automatically
Explanation:terraform import only maps an existing resource to a resource address in state. It does not write or generate the corresponding .tf configuration block — that remains the operator's responsibility.
Terraform Plan Apply Drift ImportDifficulty 1
What does terraform refresh (or the refresh step embedded in plan/apply) do?
- aIt rewrites the .tf configuration files to match whatever is currently deployed
- bIt deletes resources that are no longer referenced in the configuration
- cIt re-runs
apply to push the configuration back onto the real infrastructure - dIt queries real infrastructure and updates state to reflect the resources' actual attributes✓
Explanation:Refresh is purely a state-synchronization read: it queries each managed resource's provider API and updates the recorded state attributes to match reality. It never edits configuration files or real infrastructure.
Terraform Plan Apply Drift ImportDifficulty 1
In the context of Terraform, what is 'drift'?
- aThe gradual increase in the size of the state file over time
- bA mismatch between recorded state and the infrastructure's real-world configuration✓
- cThe normal delay between running
plan and running apply - dA Terraform provider version becoming outdated compared to the latest release
Explanation:Drift means the recorded state (and therefore the configuration Terraform believes is true) no longer matches the actual infrastructure — commonly because someone changed a resource directly in a cloud console, CLI, or another tool.
Terraform Plan Apply Drift ImportDifficulty 1
You run terraform plan right after a successful terraform apply with no configuration changes and no drift, and you see: No changes. Your infrastructure matches the configuration. What does this mean?
- aTerraform failed to reach the provider API, so it could not detect any changes
- bThe state file is corrupted and needs to be manually recreated
- cThe refreshed state matches the configuration exactly✓
- dTerraform skipped the refresh step entirely, so this message cannot be trusted
Explanation:This message is the expected, healthy outcome after a clean apply: refresh found no drift, and the configuration doesn't ask for anything different from what's already deployed.