Courseiva

TF-004 · topic practice

Implement and maintain state practice questions

Practise HashiCorp Terraform Associate TF-004 Implement and maintain state practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
20 questionsDomain: Implement and maintain state

What the exam tests

What to know about Implement and maintain state

Implement and maintain state questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Implement and maintain state exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Practice set

Implement and maintain state questions

20 questions · select your answer, then reveal the explanation

A 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?

Which TWO of the following are valid reasons to use Terraform state?

Match each Terraform state command to its action.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

List resources in the state

Show details of a single resource in state

Move an item in the state

Remove an item from the state

Download current state from backend

A team uses a Consul backend for Terraform state. They want to encrypt state at rest. What should they do?

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?

Which three of the following are valid command-line operations that modify the Terraform state? (Choose three.)

Refer to the exhibit. A user runs `terraform state list` and receives the output shown. The configuration defines an `aws_instance.web` resource with count = 3 and an `aws_s3_bucket.data` resource. After some changes, the user runs `terraform plan` and sees that the plan wants to create a new `aws_instance.web[2]` and destroy the existing `aws_instance.web[2]`. What is the most likely cause?

Exhibit

$ terraform state list
aws_instance.web[0]
aws_instance.web[1]
aws_instance.web[2]
aws_s3_bucket.data

After making manual changes to an AWS resource via the console, a Terraform user wants to update the state file to reflect those changes without modifying infrastructure. Which command should they run?

Which TWO of the following are valid methods to acquire a state lock in Terraform Cloud?

Your organization uses Terraform Cloud with a remote execution mode. There are two workspaces: `app-prod` and `app-staging`. The state for `app-prod` is stored in the `prod` workspace, and `app-staging` in the `staging` workspace. Recently, a new developer joined the team and tried to run `terraform plan` locally for the `app-staging` workspace. They received an error: "S3Backend bucket 'my-company-tf-state' does not exist." The developer is not using Terraform Cloud locally. The team uses a remote backend configuration with Terraform Cloud. What is the most likely cause?

A team uses Terraform with the `azurerm` backend. A junior engineer accidentally deletes the state file from the storage container. The team has a backup from 2 hours ago in a different container. What is the correct procedure to recover from this state loss?

Refer to the exhibit. A developer modifies the configuration by changing the resource name from 'aws_instance.web' to 'aws_instance.web2'. After running terraform plan, the output indicates that a new resource 'aws_instance.web2' will be created, but no resource will be destroyed. What should the developer do to update the state to match the configuration?

Exhibit

$ terraform state list
aws_instance.web
aws_security_group.sg

Refer to the exhibit. A developer runs terraform plan and receives this error. What should the developer do to resolve the error?

Exhibit

Error: Backend initialization required: please run "terraform init"

Reason: Backend configuration has changed.

The configured backend "s3" has changed since the last "terraform init".
Previous configuration:
  bucket = "prod-terraform-state"
  key    = "network/terraform.tfstate"
  region = "us-east-1"

New configuration:
  bucket = "prod-terraform-state"
  key    = "network/terraform.tfstate"
  region = "us-west-2"

Refer to the exhibit. An engineer modifies the instance's tags via the AWS console, then runs 'terraform apply'. The apply output shows 1 change, but the state file still shows the original tags. What is the most likely reason?

Exhibit

$ terraform apply -auto-approve
aws_instance.web_server: Modifying... [id=i-0a1b2c3d4e5f6g7h8]
aws_instance.web_server: Modifications complete after 5s [id=i-0a1b2c3d4e5f6g7h8]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

$ terraform state show aws_instance.web_server
# aws_instance.web_server:
resource "aws_instance" "web_server" {
    ami           = "ami-0c55b159cbfafe1f0"
    instance_type = "t2.micro"
    tags          = {
        "Name" = "WebServer"
    }
    subnet_id = "subnet-0a1b2c3d4e5f6g7h8"
    vpc_security_group_ids = [
        "sg-0a1b2c3d4e5f6g7h8",
    ]
}

$ terraform state pull | jq '.resources[0].instances[0].attributes_flat'
{
  "ami": "ami-0c55b159cbfafe1f0",
  "instance_type": "t2.micro"
}

A team is using a remote backend in Terraform Cloud. After a failed apply, the state file is locked. The team lead wants to unlock the state immediately. What should be done?

An organization uses Terraform with AWS S3 backend and DynamoDB for state locking. During a plan, you receive an error: 'Error acquiring the state lock'. The lock information in DynamoDB shows a lock from a previous session that crashed. What is the most appropriate next step?

A developer is working on a Terraform configuration that manages a single resource. They want to import an existing AWS EC2 instance into state. Which command should they use?

After running terraform apply, you see the error: 'Error: Error loading state: state snapshot was created by Terraform v0.12.0, but this is Terraform v1.2.0'. What should you do to resolve this?

A user wants to remove a specific resource from Terraform state without destroying the actual infrastructure. Which command should they use?

A company uses Terraform to manage infrastructure across multiple AWS accounts. They want to use a single S3 bucket to store state files for all accounts, but ensure that state files are isolated per account. What is the best approach?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Implement and maintain state sessions

Start a Implement and maintain state only practice session

Every question in these sessions is drawn from the Implement and maintain state domain — nothing else.

Related practice questions

Related TF-004 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the TF-004 exam test about Implement and maintain state?
Implement and maintain state questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Implement and maintain state questions in a focused session?
Yes — the session launcher on this page draws every question from the Implement and maintain state domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other TF-004 topics?
Use the topic links above to move to related areas, or go back to the TF-004 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the TF-004 exam covers. They are not copied from any real exam or dump site.