Terraform uses a state file to keep track of resources it manages. What is the main reason Terraform needs this state?
Think about how Terraform knows what to change when you run it multiple times.
The state file records the current status of resources Terraform manages. This helps Terraform compare the desired setup with the actual setup and make precise changes.
If the Terraform state file is deleted or lost, what will happen the next time you run terraform apply?
Consider what Terraform knows about existing resources without the state file.
Without the state file, Terraform does not know which resources already exist. It assumes none exist and tries to create them again, which can cause conflicts or duplicates.
Using remote state storage in Terraform helps teams work together. Which of the following best explains why remote state is important?
Think about how teams avoid overwriting each other's changes.
Remote state storage centralizes the state file so all team members use the same source of truth. This prevents state conflicts and supports locking mechanisms.
Terraform state files can contain sensitive information. What is the main security risk if state files are not protected?
Consider what kind of information Terraform stores in the state file.
The state file may include sensitive details like resource IDs, passwords, or API keys. If exposed, attackers could misuse this information.
Which option describes the best practice for managing Terraform state when multiple people work on the same infrastructure?
Think about how to prevent two people from changing the state at the same time.
Using a remote backend with locking prevents simultaneous changes that could corrupt the state. Versioning helps recover from mistakes.