Open
Description
This is related/complimentary to #1442 Validating types is basically a first stage of validating expressions, and so that should probably get implemented first.
Context
We do validate attributes in various contexts - for example missing required ones, or unexpected attributes.
We do not currently don't provide any validation of values though - for example we do not flag up the following:
terraform {
required_version = "invalid-constraint"
}
terraform {
required_providers {
aws = {
source = "invalid-source"
}
}
}
resource "aws_lb_listener" "name" {
default_action {
type = "invalid-type"
}
load_balancer_arn = "foo"
}
Proposal
- hcl-lang: Ensure that expressions get walked at all when validating
- hcl-lang: Introduce the concept of value-based validation into the schema
- terraform-schema: Add value-based validation to core schema where applicable
Stretch Goal
Find a way of exposing validation in a machine-readable way out of providers, such that this is available for LS.