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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 14 discussion

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

If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?

  • A. Run terraform refresh
  • B. It will happen automatically
  • C. Manually update the state fire
  • D. Run terraform import
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
tf181
Highly Voted 1 year, 12 months ago
How could change reflect in terraform without doing anything? I think A is right answer. any thoughts?
upvoted 33 times
...
G__
Highly Voted 1 year, 12 months ago
Wouldn't it be A?
upvoted 12 times
...
DarrylNg
Most Recent 2 days, 17 hours ago
https://developer.hashicorp.com/terraform/cli/commands/refresh. A should be the answer Need to run terraform plan or apply with refresh tag
upvoted 1 times
...
ravk2321
1 month, 2 weeks ago
Selected Answer: B
"The Terraform refresh command reads the current settings from all managed remote objects and updates the Terraform state to match." Warning: This command is deprecated because its default behaviour is unsafe if you have misconfigured credentials for any of your providers. See below for more information and recommended alternatives. This won't modify your real remote objects, but it will modify the Terraform state. "You shouldn't typically need to use this command, because Terraform automatically performs the same refreshing actions as a part of creating a plan in both the Terraform plan and Terraform apply commands. This command is here primarily for backward compatibility, but we don't recommend using it because it provides no opportunity to review the effects of the operation before updating the state." Link:https://developer.hashicorp.com/terraform/cli/commands/refresh
upvoted 2 times
...
akkam89
1 month, 4 weeks ago
Selected Answer: B
```The terraform refresh command reads the current settings from all managed remote objects and updates the Terraform state to match. Warning: This command is deprecated, because its default behavior is unsafe if you have misconfigured credentials for any of your providers. See below for more information and recommended alternatives.```
upvoted 2 times
...
dizzy_monkey
2 months ago
Selected Answer: A
you can do terraform refresh which is a alias for terraform apply -refresh-only -auto-approve
upvoted 2 times
...
Deva2596
3 months, 2 weeks ago
Selected Answer: A
-------------------------------
upvoted 1 times
...
samimshaikh
3 months, 4 weeks ago
Selected Answer: A
there are two ways to do this manually remove the resource using "terraform rm" from the state management and the other way is to refresh the state. Since the option given in this question is not clear enough as to run "terraform rm" or not in option C, I will go with option A is the best suited. terraform refresh
upvoted 1 times
samimshaikh
3 months, 4 weeks ago
in the context of question resource is deleted manually mean we can just refresh the state while terrafrom rm command or manually updating state file updated than resources will be still there so I will go with a TERRAFORM REFRESH
upvoted 1 times
...
...
TigerInTheCloud
4 months, 1 week ago
Selected Answer: A
A is the best answer here terraform plan -refresh-only or terraform apply -refresh-only is best practice, but not mentioned here.
upvoted 1 times
...
Rtech75
5 months ago
The wordings on B very unclear, while A is the closest possible answer. I would choose A over B for lack option and clarity on answers given
upvoted 1 times
...
IIIIIIIIIlllll
5 months, 3 weeks ago
Due to changes in terraform versions, the answer was previously A, but is now B.
upvoted 1 times
...
Tyler2023
6 months, 1 week ago
The should be B Wherever possible, avoid using 'terraform refresh' explicitly and instead rely on Terraform's behavior of automatically refreshing existing objects as part of creating a normal plan. If you don't want to automatically refresh, you can use the 'terraform apply -refresh-only' without the -auto-approve option terraform refresh is deprecated https://developer.hashicorp.com/terraform/cli/commands/refresh
upvoted 4 times
Tyler2023
6 months, 1 week ago
unless, you are using old version of TF that doesn't support the refresh-only but you shouldn't typically need to use this command, because Terraform automatically performs the same refreshing actions as a part of creating a plan in both the 'terraform plan' and ' terraform apply' commands.
upvoted 2 times
TigerInTheCloud
4 months, 1 week ago
Read the document carefully :-) The document mentions the reason for the deprecation and recommends alternatives. "A" is not the best practice in the real world, but is the best answer available here. "B" it won't automatically happen unless run some command.
upvoted 1 times
...
...
...
Badii
6 months, 3 weeks ago
Selected Answer: A
A. Run terraform refresh
upvoted 1 times
...
gofavad926
7 months ago
Selected Answer: A
It seems to be A
upvoted 1 times
...
Halimb
7 months, 3 weeks ago
The question is probably very old, posted at a time when option A was relevant and correct. It is however deprecated now and the suggested solution is "terraform apply -refresh-only". See https://developer.hashicorp.com/terraform/cli/commands/refresh
upvoted 3 times
Halimb
7 months, 3 weeks ago
Just to be clear; A is correct in this case.
upvoted 2 times
...
...
kudakk
8 months, 1 week ago
Selected Answer: A
Chatgpt A. Run terraform refresh Yes, in older versions of Terraform (before 0.15), terraform refresh could be used to reconcile the state file with the actual infrastructure. From Terraform 0.15 and later, terraform apply performs this reconciliation. B. It will happen automatically No, Terraform does not automatically detect changes made outside of its context. You must run terraform apply (or terraform plan in older versions) to see these changes and apply them to the Terraform state file.
upvoted 3 times
...
Zak_A
8 months, 2 weeks ago
Selected Answer: B
When you go to do anything useful (plan or apply) the state file is automatically refreshed, so the answer should be B. More a problem of the wording of the question.
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 ...