Terraform State Management

Configure and manage Terraform state including backends, locking, and drift detection.

This domain covers state management in Terraform. It includes understanding the local backend and state file storage, state locking mechanisms to prevent concurrent modifications, configuring remote state using backend blocks for team collaboration, and managing resource drift by detecting and reconciling differences between actual infrastructure and state.
5 minutes 5 Questions

Terraform state management is a critical concept for the Terraform Associate certification. The state file (terraform.tfstate) serves as Terraform's source of truth, mapping real-world infrastructure resources to your configuration. It tracks metadata, resource dependencies, and current infrastruct…

Concepts covered: Local state storage, The terraform.tfstate file, State file security considerations, State locking mechanisms, Preventing concurrent modifications, Force unlocking state, Backend configuration blocks, Remote backend types (S3, Azure, GCS), Backend initialization and migration, Remote state data source, Understanding resource drift, Detecting drift with terraform plan, The terraform refresh command, Reconciling state with infrastructure

Test mode:
TA-004 - Terraform State Management Example Questions

Test your knowledge of Terraform State Management

Question 1

You are a cloud infrastructure engineer at a media streaming company that uses Terraform with an S3 backend and DynamoDB for state locking. Your team operates across multiple CI/CD pipelines that occasionally trigger overlapping Terraform runs. A colleague proposes implementing a custom wrapper script that checks for lock existence before running Terraform commands, arguing this would reduce failed pipeline runs. Another colleague suggests relying solely on Terraform's built-in retry mechanism with the -lock-timeout flag. A third option discussed is implementing a queue-based system that serializes all Terraform operations before they reach the execution phase. The team asks you to evaluate which approach best aligns with Terraform's locking architecture while minimizing operational complexity.

Question 2

What type of infrastructure modification does terraform refresh detect?

Question 3

What does the tilde (~) symbol indicate in terraform plan output when drift is detected?

More Terraform State Management questions
417 questions (total)