Exam Terraform-Associate-004 Topic 3 Question 77 Discussion

Actual exam question for HashiCorp's Terraform-Associate-004 exam
Question #: 77
Topic #: 3
You use a cloud provider account that is shared with other team members. You previously used Terraform to create a load balancer that listens on port 80. After application changes, you updated the Terraform code to change the port to 443.
You run terraform plan and see that the execution plan shows the port changing from 80 to 443 like you intended and step away to grab some coffee.
In the meantime, another team member manually changes the load balancer port to 443 through the cloud provider console before you get back to your desk.
What will happen when you run terraform apply upon returning to your desk?

Suggested Answer: B Vote an answer

Terraform keeps track of the infrastructure state via the state file. When you initially ran terraform plan, Terraform determined that the port should be changed from80 to 443. However, since another team member manually modified the load balancer, Terraform's local state file is now outdated.
When you run terraform apply, Terraform willcompare the expected state (from the plan) with the actual state (from the provider API).
Since the port is already set to443, but the local state file still shows80, Terraform willfail with an errordue to the state mismatch.
To resolve this, you should run terraform refresh or use terraform apply -refresh-only to update the local state before applying changes.
Official Terraform Documentation Reference:
State Management - HashiCorp Documentation
Managing Drift in Terraform

by alexey.marchuk at May 02, 2026, 12:01 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
DeadDed
2026-05-02 12:02:50
Selected Answer: D
terraform apply will refresh state and see that port is already updated, so no changes needed and no errors.
upvoted 1 times
...
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10