20+ practice questions focused on Implement and maintain state — one of the most tested topics on the HashiCorp Terraform Associate TF-004 exam. Each question includes a detailed explanation so you learn why the right answer is correct.
Start Implement and maintain state PracticeA team uses Terraform Cloud workspaces to manage multiple environments. They notice that the state file for the production workspace is stored in a different backend than the development workspace. Which Terraform feature allows different workspaces to use different backends?
Explanation: Terraform supports partial backend configuration, where the backend block can omit certain arguments (like the bucket or path) and those values can be supplied dynamically at initialization time. By using a backend block with dynamic workspace references (e.g., `bucket = "my-state-${terraform.workspace}"` or `key = "${var.env}/terraform.tfstate"`), each workspace can resolve to a different storage location (e.g., a different S3 bucket or a different path within the same S3 bucket) for its state file. This allows the production and development workspaces to store their state in entirely different backend configurations (different instances of the same backend type) without hardcoding the configuration.
Which TWO of the following are valid reasons to use Terraform state?
Explanation: Terraform state serves two primary functions: 1. **Mapping real-world resources to configuration (Option E):** It maintains a mapping between the resources defined in your Terraform configuration files and the actual infrastructure objects created in the cloud or on-premises. This allows Terraform to know which specific cloud resource (e.g., an EC2 instance with a unique ID) corresponds to a particular `aws_instance` block in your code, enabling it to manage, update, or destroy the correct resources. 2. **Improving performance by caching resource attributes (Option D):** The state file stores the current attributes of all managed resources. When Terraform runs `plan` or `apply`, it first consults this cached state. This reduces the number of direct API calls to the cloud provider, especially for large infrastructures, thereby improving performance, reducing latency, and helping to stay within API rate limits.
Match each Terraform state command to its action.
Explanation: The correct matches are: terraform state list → List resources in state, terraform state show → Display details of a specific resource, terraform state mv → Move an item, terraform state rm → Remove an item. Common confusions include swapping list with rm or thinking mv is primarily for renaming.
A team uses a Consul backend for Terraform state. They want to encrypt state at rest. What should they do?
Explanation: The `encrypt` argument in the Terraform Consul backend configuration is used to specify an encryption key for Consul's *gossip protocol*, which encrypts *inter-agent communication*. It does *not* encrypt the state data stored at rest within Consul's KV store. Consul's KV store does not provide native, transparent encryption of values at rest. To achieve state encryption at rest while using Consul as the backend, an external mechanism like HashiCorp Vault's Transit Engine (Option E) would typically be used to encrypt the state data *before* Terraform writes it to Consul. Therefore, option D does not achieve the stated goal of encrypting state at rest.
A user runs `terraform plan` and notices that the plan includes 'Outgoing changes' for a number of resources that were not modified in the configuration. What is the most likely cause?
Explanation: When `terraform plan` shows 'Outgoing changes' for resources that were not modified in the configuration, it indicates that the actual state of the resources in the cloud provider has diverged from the desired state defined in the Terraform configuration. This phenomenon is known as 'drift'. The most common and direct cause of drift, especially when the configuration itself hasn't changed, is that the resources were manually modified outside of Terraform's management (Option B). While an 'outdated state file' (Option D) is a symptom of this drift, and `terraform plan` implicitly refreshes the state to detect these changes, the *root cause* of the state file being outdated and the drift occurring is the manual modification of resources in the cloud. Option D describes a symptom and a necessary action (refreshing the state to reflect reality), not the underlying cause of the drift itself. Option A (provider version change) can cause plan changes but is less directly related to 'drift' from manual changes. Option C (backend configuration change) is unrelated to resource drift.
+15 more Implement and maintain state questions available
Practice all Implement and maintain state questions1. Baseline your knowledge
Start with 10 questions to gauge your current understanding of Implement and maintain state. This tells you whether you need a concept refresher or just practice.
2. Review every explanation
For each question — right or wrong — read the full explanation. Understanding why an answer is correct is more valuable than knowing the answer itself.
3. Focus on exam traps
Implement and maintain state questions on the TF-004 frequently use trap wording. Look for subtle differences in answers that test your precision, not just general knowledge.
4. Reach 80% consistently
Do repeated sessions until you score 80%+ three times in a row. Then move to mixed-mode practice to test cross-topic recall under realistic conditions.
The exact number varies per candidate. Implement and maintain state is tested as part of the HashiCorp Terraform Associate TF-004 blueprint. Practicing with targeted Implement and maintain state questions ensures you can handle any format or difficulty that appears.
Yes. Courseiva provides free TF-004 practice questions across all exam topics and domains. The platform includes topic-based practice, mock exams, missed-question review, bookmarked questions, and readiness tracking — no account required.
Difficulty is subjective, but Implement and maintain state is a high-priority exam concept tested in multiple ways — direct recall, scenario analysis, and command-output interpretation. Consistent practice is the best way to build confidence.
Launch a full Implement and maintain state practice session with instant scoring and detailed explanations.
Start Implement and maintain state Practice →