Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 126 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 126
Topic #: 1
[All Terraform Associate Questions]

Terraform plan updates your state file.

  • A. True
  • B. False
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nunyabiznes
Highly Voted 1 year, 8 months ago
Selected Answer: B
B. False The terraform plan command does not update your state file. Instead, it generates an execution plan by comparing the desired state (defined in your Terraform configuration files) with the actual state (stored in the state file) of your infrastructure. The plan shows the changes that Terraform will make to the infrastructure without actually applying those changes. The state file is only updated when you run terraform apply, which applies the changes to your infrastructure and updates the state file to reflect the new state.
upvoted 17 times
Halimb
1 year, 2 months ago
A good explanation. If anyone is still doubting this; remember that the state file reflects your actual infrastructure. Since "terraform plan" does not actually change your infrastructure, it would make no sense for it to change your state file. That would make your state file invalid (state drift)!
upvoted 6 times
...
...
RVivek
Highly Voted 2 years, 1 month ago
Selected Answer: A
Terraform plan always forst check the state of existing resources refreshes/updates that to state. If there is configuration drift from last apply, then terraform will first refresh the state to respreset the current state of the resources, for example if any resouce is deleted or changed that will be upadted in the state and then the chnages to be doe will be displayed
upvoted 7 times
RonZhong
1 year, 3 months ago
Yes, everytime when I run Terraform Plan, my backend state file is also updated. I can see the last modified timestamp has been updated, even I didn't apply the change.
upvoted 2 times
...
...
AkaAka4
Most Recent 6 months, 4 weeks ago
Selected Answer: A
Refer to https://stackoverflow.com/questions/66240556/terraform-plan-not-updating-state-file
upvoted 1 times
AkaAka4
6 months, 4 weeks ago
Check the 2nd last comment in the link, should be B. Apologies.
upvoted 1 times
...
...
Ajit18
8 months, 1 week ago
B. False Terraform plan does not update the state file itself. It performs an in-memory refresh to reconcile the state file with the actual infrastructure, but it doesn't modify the state file on disk. The update to the state file happens during terraform apply if there are changes required.
upvoted 1 times
...
dizzy_monkey
8 months, 2 weeks ago
Selected Answer: A
"A" should be correct : "Terraform automatically performs the same refreshing actions as a part of creating a plan in both the terraform plan and terraform apply commands." https://developer.hashicorp.com/terraform/cli/commands/refresh
upvoted 1 times
...
91576b8
9 months, 2 weeks ago
Selected Answer: A
when you run terraform plan , it will refresh the state file automaticlly
upvoted 1 times
...
boapaulo
9 months, 4 weeks ago
The terraform plan command does not update the state file. It performs a refresh of the state in-memory to generate an execution plan, but it does not persist these changes to the state file. The state file is updated when you run terraform apply.
upvoted 1 times
...
vipulchoubisa
10 months, 2 weeks ago
create one simple instance and change the tags from AWS console. After this run terraform plan command. As a result it wont update the state file with new tags. So answer is B
upvoted 1 times
...
Demonik
11 months, 3 weeks ago
Selected Answer: B
Nope.Plan does not change state file.But others like apply destroy after approve will :)
upvoted 1 times
...
pamfidelis
1 year, 1 month ago
Selected Answer: A
A. True "You can also update your state file without making modifications to your infrastructure using the -refresh-only flag for plan and apply operations." https://developer.hashicorp.com/terraform/tutorials/state/refresh
upvoted 1 times
TigerInTheCloud
11 months, 1 week ago
terraform plan -refresh-only only make the plan of changing state file.
upvoted 1 times
...
...
gofavad926
1 year, 1 month ago
Selected Answer: B
B, terraform plan doesn't update the state
upvoted 1 times
...
nahed
1 year, 2 months ago
Selected Answer: A
terraform state will UPDATE your state file in case you change the resources outside the terraform. IT will "sync" your state file with the actual infrastructure.
upvoted 1 times
...
kudakk
1 year, 3 months ago
Selected Answer: B
The terraform plan command does not change the state of your infrastructure. It creates an execution plan that lets you preview the changes that Terraform plans to make to your infrastructure
upvoted 1 times
...
foreverlearner
1 year, 4 months ago
"To determine whether state drift occurred, Terraform performs a refresh operation before it begins to build an execution plan. This refresh step pulls the actual state of all of the resources currently tracked in your state file. --> Terraform does not update your actual state file <--, but captures the refreshed state in the plan file." (https://developer.hashicorp.com/terraform/tutorials/cli/plan) "You can also update your state file without making modifications to your infrastructure using the -refresh-only flag for plan and apply operations." (https://developer.hashicorp.com/terraform/tutorials/state/refresh) So plan doesn't update the state file (just an in-memory sync) unless you specify the --refresh-only flag
upvoted 5 times
...
milan92stankovic
1 year, 5 months ago
Selected Answer: A
terraform state will UPDATE your state file in case you change the resources outside the terraform. IT will "sync" your state file with the actual infrastructure.
upvoted 4 times
...
Ni33
1 year, 6 months ago
Selected Answer: B
B is the correct answer
upvoted 1 times
...
ale_brd_111
1 year, 9 months ago
Selected Answer: B
b is the correct answer
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...