Skip to content

Introduce attribute (interpolated) value based validation #1483

Open
@radeksimko

Description

@radeksimko

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions