Interview Questions/Phone Screen/Purpose of Terraform State
IntermediatePhone
2 min

Purpose of Terraform State

TerraformIaCCloud
Advertisement
Interview Question

What is Terraform state and why is it important to store it remotely?

Key Points to Cover
  • State maps resources in cloud to config for diff/plan
  • Remote state enables collaboration and locking
  • Protects against drift and concurrent changes
Evaluation Rubric
Defines Terraform state accurately34% weight
Explains benefits of remote state/locking33% weight
Mentions drift/concurrency concerns33% weight
Hints
  • 💡Backends: S3+DynamoDB lock, GCS, Azure Blob.
Common Pitfalls to Avoid
  • ⚠️Forgetting to configure remote state and state locking, especially when working in a team or CI/CD environment, leading to state conflicts and corruption.
  • ⚠️Manually editing the Terraform state file, which can easily lead to inconsistencies, corruption, or a misalignment between the state and the actual infrastructure.
  • ⚠️Storing sensitive data directly within the state file without proper encryption or integrating with a dedicated secrets management solution.
  • ⚠️Using a single, monolithic state file for a vast or overly complex infrastructure, leading to slow `plan` and `apply` operations and a larger blast radius for changes.
  • ⚠️Ignoring or not regularly reconciling state drift, which causes the Terraform state to diverge from the actual cloud infrastructure, leading to unexpected changes or inability to manage resources.
Potential Follow-up Questions
  • What’s `terraform import` for?
  • How do workspaces relate to state?
Advertisement