1. HashiCorp Terraform Documentation
"Command: apply": "By default
apply will also run terraform plan to generate a plan before prompting for approval. This is a convenience feature
and it is recommended to run terraform plan directly and save the plan to a file to be sure that you are applying the changes you expect." This confirms that apply runs its own plan
which includes a refresh.
Source: HashiCorp Developer
developer.hashicorp.com/terraform/cli/commands/apply. Accessed on the current date.
2. HashiCorp Terraform Documentation
"Command: plan": "As part of creating a plan
Terraform reads the current state of any already-existing remote objects to make sure that the Terraform state is up-to-date. This is what we refer to as a "refresh" of the state." This explains that the planning process
whether invoked by plan or apply
inherently involves a refresh against the real infrastructure.
Source: HashiCorp Developer
developer.hashicorp.com/terraform/cli/commands/plan. Accessed on the current date.
3. HashiCorp Terraform Documentation
"State: Resource Drift": "When the real-world resource differs from Terraform's state file
this is called "drift". [...] When you run terraform plan or terraform apply
Terraform will read the current attributes of the existing resource and update the state file. This detects the drift and may plan to update the resource to match the configuration." This directly addresses the scenario in the question
defining drift and explaining how plan and apply detect and handle it.
Source: HashiCorp Developer
developer.hashicorp.com/terraform/language/state#resource-drift. Accessed on the current date.