Open
Description
Context
Discovered originally as part of hashicorp/vscode-terraform#1597
In Terraform [language], the provider
blocks are generally considered a part of the configuration which does not "do" anything - i.e. does not create/update/delete anything, but it typically sets up the authentication and generally configures things, such that each resource or data source can leverage that and focus on the "doing".
This is why Terraform currently also ignores provider
blocks without any corresponding resources and data sources and ignores those during plan
, apply
or validate
.
terraform {
required_providers {
github = {
source = "integrations/github"
}
}
}
provider "github" {
foobar {}
does_not_exist = true
}
^ the above will go unnoticed by terraform validate
, terraform plan
and terraform apply
This can lead to user confusion and in practice it represents "dead code".
Proposal
- Introduce new warning diagnostic that highlights redundant
provider
blocks such as in the example above - Provide
quickfix
code action which removes such redundantprovider
blocks - (re)consider validating such redundant provider blocks further - e.g. for required attributes, blocks, invalid attribute names etc.