Create HCL Schemas using HCL files.
This repository includes:
- Go library for validating HCL files according to their
*.schema.hclschemas. - Go CLI for verifying HCL files via command-line.
- VSCode Extension for verifying HCL files inside the editor.
You can define an schema by creating a *.schema.hcl:
example.schema.hcl:
__schema = "https://raw.githubusercontent.com/avestura/hcl-schema/refs/heads/main/schema/draft/2025-10/.schema.hcl"
__id = "https://raw.githubusercontent.com/avestura/hcl-schema/refs/heads/main/example.schema.hcl"
body {
attribute "myattr" {
required = true
}
block_header "tag" {
label_names = ["name1"]
body {
attribute "x" {}
}
}
}Which parses and accepts HCL files like this:
// Defines an HCL file like this:
myattr = "x"
tag "name" {
x = 2
}
tag "name2" {}block_headeris equivalent ofhcl.BlockHeaderSchemaattributeis equivalent ofhcl.AttributeSchemabodyis equvalent ofhcl.BodySchema
Get the VSCode Extension at marketplace.visualstudio.com/items?itemName=avestura.hcl-schema
The root HCL schema defines the schema itself (its own body).
