TF-004 Implement and maintain state Practice Question
Exhibit
$ terraform plan -out=tfplan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_instance.web_server will be created
+ resource "aws_instance" "web_server" {
+ ami = "ami-0c55b159cbfafe1f0"
+ instance_type = "t2.micro"
+ subnet_id = "subnet-0a1b2c3d4e5f6g7h8"
+ vpc_security_group_ids = [
+ "sg-0a1b2c3d4e5f6g7h8",
]
+ tags = {
+ "Name" = "WebServer"
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
─────────────────────────────────────────────────────────────────────────────
Saved the plan to: tfplan
To perform exactly these actions, run the following command to apply:
terraform apply "tfplan"
$ terraform apply tfplan
aws_instance.web_server: Creating...
aws_instance.web_server: Still creating... [10s elapsed]
aws_instance.web_server: Creation complete after 12s [id=i-0a1b2c3d4e5f6g7h8]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
$ terraform state pull | jq '.serial'
2Refer to the exhibit. After applying the plan, the state serial number is 2. What was the serial number before the apply?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
1
The serial number increments by 1 each time state is modified. Initially the state had serial 1 (or 0 if fresh). After the apply adding one resource, serial becomes 2, so previous serial was 1.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
0
Why it's wrong here
A serial increment of 0 would indicate that no changes were applied to the Terraform state file, or that the `terraform apply` operation resulted in no actual infrastructure modifications. This contradicts the premise of "after applying the plan," which implies a successful state update. Terraform's state serial is designed to increment with every successful state write, ensuring a unique identifier for each version of the state.
- ✓
1
Why this is correct
The Terraform state serial consistently increments by exactly one (1) for every successful modification to the state file, regardless of the number of resources added, changed, or destroyed within that single `terraform apply` operation. This behavior ensures a clear, sequential version history of the infrastructure's configuration as managed by Terraform. Therefore, after applying a plan that modifies the state, the serial will increase by 1.
- ✗
3
Why it's wrong here
An increment of 3 would imply that three distinct state modification operations occurred during the single `terraform apply` execution. Terraform's state serial management is designed such that a single `apply` command, even if it modifies multiple resources, results in only one increment to the state serial, not multiple increments based on the number of resource changes.
- ✗
2
Why it's wrong here
An increment of 2 would suggest that two separate state modification operations were performed sequentially during the process of applying a single plan. While the *final* serial number might be 2 if the *initial* serial was 0 and one change occurred, the serial itself increments by 1 per successful state write, not by 2. This option incorrectly represents the standard increment value for a single state modification.
Go deeper
Related to this question
About these practice questions
Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.