0
0
Terraformcloud~20 mins

Why state should not be edited manually in Terraform - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform State Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is manual editing of Terraform state risky?

Terraform uses a state file to track resources it manages. What is the main risk of manually editing this state file?

AIt improves performance by reducing the size of the state file.
BIt automatically updates all resources to the latest version.
CIt encrypts the state file to enhance security.
DIt can cause Terraform to lose track of resources, leading to unexpected changes or deletions.
Attempts:
2 left
💡 Hint

Think about what happens if Terraform's record of resources does not match reality.

Architecture
intermediate
2:00remaining
What happens if Terraform state is corrupted?

Imagine the Terraform state file is corrupted or inconsistent. What is the likely outcome when you run terraform apply?

ATerraform will switch to a backup cloud provider.
BTerraform may attempt to recreate or delete resources incorrectly, causing service disruption.
CTerraform will automatically fix the corrupted state without user intervention.
DTerraform will ignore the state and only use the configuration files.
Attempts:
2 left
💡 Hint

Consider how Terraform relies on the state file to know what exists.

security
advanced
2:00remaining
Security risks of manual Terraform state edits

Which security risk is most associated with manually editing Terraform state files?

AImproving audit logs by manual changes.
BPreventing unauthorized users from accessing the state file.
CExposing sensitive data like passwords or keys stored in the state file.
DAutomatically encrypting the state file with weak keys.
Attempts:
2 left
💡 Hint

Think about what kind of information Terraform state files contain.

Best Practice
advanced
2:00remaining
Recommended way to fix Terraform state issues

If you find an error in your Terraform state, what is the best practice to fix it without manual editing?

AUse Terraform commands like <code>terraform state rm</code> or <code>terraform import</code> to adjust state safely.
BOpen the state file in a text editor and change resource IDs directly.
CDelete the state file and start from scratch.
DIgnore the error and continue applying changes.
Attempts:
2 left
💡 Hint

Terraform provides commands to manage state safely.

service_behavior
expert
2:00remaining
Effect of manual state edits on Terraform plan output

You manually edit the Terraform state file to remove a resource entry but do not delete the actual resource in the cloud. What will terraform plan show?

ATerraform will plan to create the resource again because it thinks it does not exist.
BTerraform will plan to delete the resource because it is missing from the state.
CTerraform will show no changes because the resource exists in the cloud.
DTerraform will fail with a syntax error in the state file.
Attempts:
2 left
💡 Hint

Think about how Terraform compares state to actual resources.