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 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: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
tf181
Highly Voted 2 years, 6 months ago
How could change reflect in terraform without doing anything? I think A is right answer. any thoughts?
upvoted 35 times
...
G__
Highly Voted 2 years, 6 months ago
Wouldn't it be A?
upvoted 12 times
...
Labman32
Most Recent 1 week ago
A. is correct but now as a best practice the correct way should be running terraform apply with the -refresh-only, this way you will get a prompt when it compares and see's that the deleted infrastructure is missing and will show you during your plan.
upvoted 1 times
...
erif
1 month, 2 weeks ago
Selected Answer: C
The best practice when infrastructure is manually destroyed is to manually update the state file (option C). This means the need to update Terraform's state file to reflect that the resource has been destroyed outside of Terraform. Specifically: You can use the terraform state rm command to remove the resource from the state file, as it no longer exists. Alternatively, you could manually edit the state file, but this is risky and generally not recommended. Other options like terraform refresh will only update the state based on the existing infrastructure, but if the resource was destroyed outside of Terraform, it will still appear in the state file unless manually removed.
upvoted 1 times
...
nss373
1 month, 3 weeks ago
Answer is C. We have to manually remove the the resource from state file.
upvoted 1 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
...
ravk2321
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 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
...
fasaleAkshay
1 month, 4 weeks ago
Selected Answer: A
terraform refresh is used to reconcile the Terraform state with the real-world infrastructure. If you manually destroy infrastructure, the Terraform state will still show that the resource exists. Running terraform refresh updates the state to reflect the current state of the infrastructure, marking resources that were manually destroyed as no longer existing. B. It will happen automatically: No, Terraform does not automatically update its state when infrastructure is changed outside of Terraform. You need to run a command like terraform refresh.
upvoted 1 times
...
Mattt
2 months, 1 week ago
Selected Answer: B
he terraform refresh command : 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 1 times
...
bora4motion
3 months ago
Selected Answer: A
I'd say it's A but the question is weird and I got tricked. By manually I thought it'd be "terraform destroy" but it seems like manually mean go into the cloud and delete stuff, therefore you need to refresh the file.
upvoted 1 times
...
enklau
4 months ago
A is correct, but now as a best practice the correct way should be running terraform apply with the -refresh-only flag
upvoted 1 times
...
callmegio
5 months, 1 week ago
A is the correct answer. Terraform says Warning: This command is deprecated, because its default behavior is unsafe if you have misconfigured credentials for any of your providers. 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 1 times
...
starkonbullet
6 months, 1 week ago
Selected Answer: A
The command had been deprecated already. Use -refresh-only option along with terraform plan or terraform apply for the same operation.
upvoted 1 times
...
deepakpamban
6 months, 3 weeks ago
terraform refresh is not depricated. Answer is A
upvoted 1 times
...
DarrylNg
7 months 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
...
dizzy_monkey
9 months ago
Selected Answer: A
you can do terraform refresh which is a alias for terraform apply -refresh-only -auto-approve
upvoted 3 times
...
Deva2596
10 months, 2 weeks ago
Selected Answer: A
-------------------------------
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 ...