HashiCorp Terraform Associate (004) Question 163
Single answer6a Describe the local backendA small development team is using Terraform to manage a test environment from their laptops. They have not configured any backend block, and each engineer runs Terraform from a copy of the same configuration directory stored locally. One engineer applies a change successfully, but later another engineer runs terraform plan from their own laptop and Terraform proposes recreating resources that already exist. Which explanation best describes why this happened?
- A
Terraform is using the local backend by default, so each engineer has a separate local state file unless they explicitly share state through another backend.
- B
The local backend automatically merges state changes across team members whenever they use the same working directory name.
- C
Without a backend block, Terraform runs in stateless mode and discovers all infrastructure directly from the provider on each plan.
- D
The local backend stores state in the provider service by default, so the second engineer's laptop probably failed to download the latest state.
Show answer and explanation
Correct answer: A
Explanation
This scenario highlights the default behavior of Terraform backends: if you do not explicitly configure one, Terraform uses the local backend. The local backend stores state on the local filesystem, which works for individual use but creates collaboration risks because each user can end up with a different copy of state. In a team setting, this often leads to drift between local state files, duplicate resource creation attempts, or conflicting changes. HashiCorp documentation describes the local backend as the default backend and notes that it stores state locally. Best practice for shared team workflows is typically to use a remote backend that provides a shared source of truth for state and, depending on the backend, additional collaboration features such as locking.
- A. Correct.
Correct. If no backend is configured, Terraform uses the local backend by default. With the local backend, state is stored on the local filesystem for that working directory, typically in a terraform.tfstate file. If multiple engineers each run Terraform from separate local copies of the configuration, they each maintain different state unless they manually share it. That can cause Terraform to believe existing resources are unmanaged and propose creating or recreating them.
- B. Incorrect.
Incorrect. The local backend does not provide shared state synchronization or automatic merging across machines. State is just stored locally on disk. Team collaboration problems like this are a common reason to use a remote backend instead of the default local backend.
- C. Incorrect.
Incorrect. Terraform is not stateless when no backend block is present. It still uses state, and by default that state is managed by the local backend. While providers can refresh known objects during planning, Terraform does not discover and adopt all infrastructure automatically just because no backend is configured.
- D. Incorrect.
Incorrect. The local backend does not store state in the provider platform or cloud service. It stores state locally on disk. Confusing provider-managed infrastructure with Terraform backend storage is a common misconception.