Terraform will ignore variables and locals that are not used. It will refresh declared data sources regardless of usage. However, unreferenced variables likely indicate either a bug (and should be referenced) or removed code (and should be removed).
variable "not_used" {}
variable "used" {}
output "out" {
value = var.used
}
It is recommended to remove the declaration.
For variable and data, remove the entire block. For a local value, remove the attribute from the locals block.
While data sources should generally not have side effects, take greater care when removing them. For example, removing data `"http"` will cause Terraform to no longer perform an HTTP `GET` request during each plan.
If a data source is being used for side effects, add an annotation to ignore it:
```hcl
# skipcq: TF-L0039
data "http" "example" {
url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"
}