Which Terraform command assists in detecting and managing drift?

Master the HashiCorp Terraform Test with these flashcards and multiple choice questions. Each question includes hints and explanations to prepare you effectively. Set yourself up for success!

The command that assists in detecting and managing drift is Terraform refresh, which retrieves the current state of the infrastructure and updates the Terraform state file accordingly. When infrastructure changes outside of Terraform (for example, manual changes made through a cloud provider’s console), those updates are considered "drift."

When you run the Terraform refresh command, it will check the actual state of your resources against what is recorded in the Terraform state file. If there are discrepancies, the command updates the state file to reflect the current reality in your infrastructure. This ensures that your Terraform environment is aware of any changes that have occurred, allowing you to manage them effectively.

While the Terraform plan command shows proposed changes to be made to infrastructure based on the current configuration and the state file, it does not directly detect drift. Instead, it evaluates what Terraform would apply if you executed a plan, based on the differences between the configuration and the state file. Terraform state manages the state file but does not actively detect changes in the real-world resources. Lastly, Terraform validate checks for syntax errors and best practices in the configuration files, but it does not deal with the actual state of infrastructure.

Therefore, using the refresh command is crucial in identifying drift, so that you can address it appropriately in

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy