Hashicorp Certified Terraform Associate 003 · Free Practice Question Easy
Question 24
Which common action does not cause Terraform to refresh its state?
-
A
terraform destroy -
B
terraform apply -
C
terraform state list -
D
terraform plan
Reveal correct answer
Correct answer: C
Explanation
Running a terraform state list does not cause Terraform to refresh its state. This command simply reads the state file but it will not modify it.
terraform plan will refresh the current state of any existing remote objects to make sure that the Terraform state is up-to-date --> see information here
WRONG ANSWERS:
When running a plan, apply, or destroy, Terraform needs to refresh state to ensure that it has the latest information about the managed resources so it understands what changes should be made when applying the desired state configuration.
A.
Running terraform destroy instructs Terraform to destroy all the resources defined in the configuration. This action will cause Terraform to refresh its state to reflect the changes made during the destruction process.
B.
terraform apply is the command used to apply the changes described in the Terraform configuration to the real-world infrastructure. When you run terraform apply, Terraform will refresh its state to reflect the changes made during the apply process.
C.
Running terraform state list does not cause Terraform to refresh its state. This command simply lists the resources in the state file without making any changes to the infrastructure. It is a read-only operation and does not trigger a state refresh.
D.
When you run terraform plan, Terraform generates an execution plan showing what actions it will take to change the infrastructure to match the current configuration.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
