Skip to content
Novus Examples
hcl1.2 KB

HCL2 Image Build Definition

A generic HCL2 image-build definition exercising the grammar rather than any vendor schema: labelled blocks, a list variable, locals, an indent-stripping heredoc with an interpolation inside it, and a for expression producing a list.

Preview — first 50 lineshcl
# Generic HCL2 image-build definition. Not tied to any one tool: the point is the HCL2 grammar
# (blocks with labels, heredocs, interpolation, functions), not a vendor's schema.
variable "version_tag" {
  type    = string
  default = "1.4.0"
}

variable "channels" {
  type    = list(string)
  default = ["stable", "edge"]
}

locals {
  build_name = "novus-${var.version_tag}"
  timestamp  = "2026-01-15T09:30:00Z"
}

source "example-builder" "base" {
  image_family  = "example-linux-1"
  machine_type  = "example-medium"
  disk_size_gb  = 20
  ssh_username  = "builder"

  labels = {
    name    = local.build_name
    channel = var.channels[0]
  }
}

build {
  name    = local.build_name
  sources = ["source.example-builder.base"]

  provisioner "inline-notes" {
    notes = <<-EOT
      This heredoc is indented content with the leading whitespace stripped by <<-.
      It exists so an HCL parser has a real multi-line string to handle,
      including an interpolated value: ${local.build_name}.
    EOT
  }

  provisioner "file-list" {
    files = [
      for channel in var.channels : "manifests/${channel}.json"
    ]
  }

  post-processor "manifest" {
    output     = "manifest.json"
    strip_path = true
53 lines total — download for the full file.

Specifications

Grammar
HCL2
Blocks
5
Labelled Blocks
4
Heredocs
1
Heredoc Style
<<- (indent-stripping)
For Expressions
1
Interpolations
3

Testing contract

Expected to pass
Scenario
Parse HCL2 including an indent-stripping heredoc that contains an interpolation
Expected result
The <<-EOT heredoc parses with its leading indentation removed and its ${local.build_name} interpolation recorded as a reference, not as literal text

What is a .hcl file?

HCL (HashiCorp Configuration Language) is the block-structured configuration language behind Terraform, Packer, Nomad, Consul, and Vault. A document is a sequence of attributes (`name = expression`) and blocks (a type, zero or more string labels, and a braced body), with support for heredocs, function calls, conditionals, and for-expressions. It is designed to be both hand-written and machine-generated, and has a documented JSON-equivalent syntax.

How to use this file

Use an example .hcl file to test HCL parsers, configuration linters, and JSON-syntax converters, exercising nested blocks with multiple labels, heredoc indentation, and comment styles (`#`, `//`, and `/* */`).

How to use this file for testing

“HCL2 Image Build Definition” is a deterministic Novus Examples fixture for Config testing, Config parsing, Syntax highlighting. TOML, INI, YAML, .env, and dotfile configuration samples with nested sections and typed values — for testing config parsers, loaders, and environment tooling.

Documented properties for this file: HCL · 1,224 bytes. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Pipeline and infrastructure fixtures are inert configuration: steps reference fictional images and scripts, and nothing here executes. Run your linter, schema validator, migrator, or policy engine against them, and expect the deprecated-syntax and intentionally invalid variants to be rejected.

Point your config loader at the file and assert it reads the documented sections and typed values, including any deliberately-tricky nesting or comments.

Generated by generation/pipelines.py. Free for any use, no attribution required — license.