0
0
Terraformcloud~20 mins

Local state behavior in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Local State Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
How does Terraform local state behave after resource deletion?

Consider a Terraform configuration where a resource is created and then manually deleted outside Terraform (e.g., via cloud console). What will Terraform's local state file reflect after this manual deletion?

AThe local state still shows the resource as existing until you run 'terraform refresh' or 'terraform apply'.
BThe local state automatically updates and removes the resource immediately after manual deletion.
CTerraform local state deletes the resource entry only after running 'terraform destroy'.
DTerraform local state never tracks resource existence and only stores configuration.
Attempts:
2 left
💡 Hint

Think about how Terraform tracks resources and when it updates its local state file.

Architecture
intermediate
2:00remaining
What happens to local state when multiple users run Terraform independently?

Two team members run Terraform commands independently on the same infrastructure but on their own local machines using local state files. What is the likely outcome?

ATerraform automatically merges local state files from different users to keep them consistent.
BTerraform locks the infrastructure to prevent multiple users from running commands simultaneously.
CLocal state files are shared automatically via cloud provider APIs to avoid conflicts.
DEach local state file may become out of sync, causing conflicts and potential resource duplication or deletion.
Attempts:
2 left
💡 Hint

Consider how local state files are stored and shared.

Configuration
advanced
2:00remaining
What error occurs when Terraform local state file is corrupted?

After a failed Terraform operation, the local state file becomes corrupted. What error message will Terraform most likely show when you try to run 'terraform plan'?

AError: Terraform configuration syntax error
BError: Failed to load state: invalid character '<' looking for beginning of value
CError: No changes. Infrastructure is up-to-date
DError: Resource not found in cloud provider
Attempts:
2 left
💡 Hint

Think about what happens if the state file content is unreadable or malformed JSON.

security
advanced
2:00remaining
What is a security risk of storing Terraform local state on a shared network drive?

Storing Terraform local state files on a shared network drive accessible by multiple users can cause which security risk?

AUnauthorized users may access sensitive data like passwords or keys stored in the state file.
BTerraform will automatically encrypt the state file, so no risk exists.
CStoring state on a shared drive improves security by centralizing access control.
DThe state file will be deleted automatically after each run to prevent leaks.
Attempts:
2 left
💡 Hint

Consider what kind of data Terraform state files contain.

Best Practice
expert
2:00remaining
Which approach best prevents local state conflicts in a team environment?

Your team manages infrastructure with Terraform. To avoid local state conflicts and ensure consistent state, which approach is best?

ADisable state locking and rely on manual communication to avoid conflicts.
BEach user keeps their own local state file and manually merges changes.
CUse a remote state backend like Terraform Cloud or S3 with state locking enabled.
DStore local state files on a shared network drive without locking.
Attempts:
2 left
💡 Hint

Think about how to share state safely and avoid conflicts.