HCL Format + Examples

Information on using the HCL format to define Scale Extensions.

The Hashicorp Configuration Language (HCL) is used to define extensions in human readable way.

HCL Basics

Attributes

In HCL, an attribute is a fundamental element that assigns a value to a name. Attributes are key-value pairs, and their values can be simple literals (like strings or numbers), or they can be more complex expressions.

For example:

field1 = "a field"
field2 = 2

Blocks

blocks, in HCL, are structures representing a higher-order configuration container that can hold attributes and, in some cases, nested blocks. Blocks form the core structure of HCL-based configurations, especially in tools like Terraform, and in Scale Signatures and Extensions.

A block in HCL has a type, zero or more labels, and a body. The type defines the kind of configuration the block will hold (like a resource, or in the case below, a model). Labels are additional identifiers to distinguish or parameterize the block further. The body of the block contains attributes and possibly nested blocks.

model Thing {
  string "name" {
    default  = ""
    accessor = true
  }
}

the types of the blocks for extensions include: interface, function, enum, model.

Example Extensions

Edit on GitHub

Last updated on

On this page