Table of Contents
HashiCorp Configuration Language (HCL)
Return to HashiCorp, Terraform, DevOps, Automation, Configuration automation
“HCL (HashiCorp Configuration Language) is a configuration language built by HashiCorp. The goal of HCL is to build a structured configuration language that is both human and machine friendly for use with command-line tools, but specifically targeted towards DevOps tools, servers, etc.
TLDR: HashiCorp Configuration Language (HCL) is a declarative language introduced by HashiCorp in 2014, designed to define infrastructure resources and automate provisioning. Widely used in tools like Terraform and Vault, HCL emphasizes simplicity and readability, enabling developers to describe complex configurations through a human-friendly syntax. It bridges the gap between machine-executable code and human-readable documentation.
https://en.wikipedia.org/wiki/Terraform_(software)
HCL supports both declarative and imperative workflows, allowing users to specify the desired state of infrastructure or define operational tasks. The language uses a JSON-compatible syntax with blocks, attributes, and nested structures to define resources, such as virtual machines or databases. For example, in Terraform, an HCL file can define a complete cloud environment by specifying resources and their interdependencies, ensuring consistent deployments across environments.
https://developer.hashicorp.com/terraform/language
The flexibility of HCL extends to its interoperability, as configurations can be combined with dynamic expressions, variable files, and modules for reusable and scalable workflows. HCL also integrates seamlessly with other HashiCorp tools, making it a core component of Infrastructure as Code (IaC) practices. By simplifying infrastructure definition and enhancing collaboration, HashiCorp HCL has become a critical element of modern DevOps and cloud-native architectures.
https://www.hashicorp.com/resources/hcl-overview
HCL is also fully JSON compatible. That is, JSON can be used as completely valid input to a system expecting HCL. This helps makes systems interoperable with other systems.
HCL is heavily inspired by libucl, nginx configuration, and others similar. Why?
A common question when viewing HCL is to ask the question: why not JSON, YAML, etc.?
Prior to HCL, the tools we built at HashiCorp used a variety of configuration languages from full programming languages such as Ruby to complete data structure languages such as JSON. What we learned is that some people wanted human-friendly configuration languages and some people wanted machine-friendly languages.
JSON fits a nice balance in this, but is fairly verbose and most importantly doesn't support comments. With YAML, we found that beginners had a really hard time determining what the actual structure was, and ended up guessing more often than not whether to use a hyphen, colon, etc. in order to represent some configuration key.
Full programming languages such as Ruby enable complex behavior a configuration language shouldn't usually allow, and also forces people to learn some set of Ruby.
Because of this, we decided to create our own configuration language that is JSON-compatible. Our configuration language (HCL) is designed to be written and modified by humans. The API for HCL allows JSON as an input so that it is also machine-friendly (machines can generate JSON instead of trying to generate HCL).
Our goal with HCL is not to alienate other configuration languages. It is instead to provide HCL as a specialized language for our HashiCorp tools, and JSON as the interoperability layer.”
Introduction to HashiCorp Configuration Language (HCL)
HashiCorp Configuration Language (HCL) was introduced as the foundational element for configuring products in the HashiCorp suite, including Terraform, Vault, Consul, and Nomad. Launched in conjunction with Terraform in July 2014, HCL is a human-readable configuration language designed to describe infrastructure in a declarative manner. The creation of HCL was motivated by the need for a more structured yet readable format to manage complex infrastructure setups, bridging the gap between human-friendly configuration files and machine-readable JSON.
Design Principles and Syntax
HCL's syntax is distinct and user-friendly, aiming to strike a balance between human-readable configuration files and machine-friendly data formats like JSON. It employs a block structure that organizes configuration into sections, making it easy to read and understand at a glance. This structure supports basic data types, such as strings, numbers, and booleans, and allows for more complex structures like lists and maps. The design of HCL emphasizes clarity and simplicity, enabling users to define infrastructure with concise and expressive code.
HCL in [[HashiCorp]] Products
While HCL is most commonly associated with Terraform, it is also the configuration language for other HashiCorp products such as Vault, Consul, and Nomad. This consistent use of HCL across the HashiCorp suite simplifies the learning curve for users working with multiple HashiCorp tools. Each product leverages HCL to define configurations specific to its domain, whether it's provisioning infrastructure with Terraform, managing secrets with Vault, configuring service networking with Consul, or scheduling and running applications with Nomad.
HCL 2.0 Enhancements
The introduction of HCL 2.0 brought significant enhancements to the language, including dynamic expressions, improved looping and conditionals, and richer data manipulation capabilities. Released with Terraform 0.12, HCL 2.0 aimed to address some of the limitations of the original version by making the language more flexible and powerful for complex infrastructure as code (IaC) scenarios. These improvements have made it easier for users to implement more dynamic and reusable configurations, further solidifying HCL's position as a leading tool in the IaC domain.
Integration with Other Technologies
HCL's design allows for seamless integration with JSON, enabling users to use either format for configuration or to interoperate between them. This flexibility ensures that HCL can fit into a wide range of workflows and systems, making it a versatile choice for infrastructure management. Additionally, the widespread adoption of HCL in the IaC community has led to tooling and support in various text editors and IDEs (Integrated Development Environments), further enhancing its usability and accessibility for developers and operators.
Future Directions and Community Impact
Since its introduction, HCL has had a profound impact on the infrastructure as code (IaC) community, enabling more accessible and manageable infrastructure management practices. As the adoption of cloud computing and automated infrastructure continues to grow, the role of HCL is likely to expand further. HashiCorp's ongoing development of HCL, driven by community feedback and evolving industry needs, will continue to focus on enhancing its expressiveness, usability, and integration capabilities. The future of HCL promises to bring even more powerful and user-friendly features to the forefront of infrastructure automation and management.
HCL Syntax
For a complete grammar, please see the parser itself. A high-level overview of the syntax and grammar is listed here.
- Single line comments start with # or //
- Multi-line comments are wrapped in /* and */. Nested block comments are not allowed. A multi-line comment (also known as a block comment) terminates at the first */ found.
- Values are assigned with the syntax key = value (whitespace doesn't matter). The value can be any primitive: a string, number, boolean, object, or list.
- Strings are double-quoted and can contain any UTF-8 characters. Example: “Hello, World”
- Multi-line strings start with «EOF at the end of a line, and end with EOF on its own line (here documents). Any text may be used in place of EOF. Example:
«FOO hello world FOO
Numbers are assumed to be base 10. If you prefix a number with 0x, it is treated as a hexadecimal. If it is prefixed with 0, it is treated as an octal. Numbers can be in scientific notation: “1e10”.
Boolean values: true, false
Arrays can be made by wrapping it in []. Example: [“foo”, “bar”, 42]. Arrays can contain primitives, other arrays, and objects. As an alternative, lists of objects can be created with repeated blocks, using this structure:
service { key = "value" }
service { key = "value" }
Objects and nested objects are created using the structure shown below:
variable “ami” {
description = "the AMI to use"}
This would be equivalent to the following json:
{
"variable": { "ami": { "description": "the AMI to use" } }}
See also
External sites
Cloud Monk is Retired ( for now). Buddha with you. © 2025 and Beginningless Time - Present Moment - Three Times: The Buddhas or Fair Use. Disclaimers
SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.
Terraform, Vault, Consul, Nomad, Vagrant, Packer, Boundary, Waypoint, HCP Consul, HCP Vault, HCP Packer, HCP Boundary, HCP Nomad, HCP Terraform, Sentinel, Terraform Cloud, Terraform Enterprise, Vault Enterprise, Consul Enterprise, Nomad Enterprise, Boundary Enterprise, Waypoint Enterprise, Terraform Cloud Business, Vault Cloud Platform, Consul Service Mesh, Vault Secrets management, Vault identity-based access, Vault data encryption, Consul Kubernetes, Nomad Kubernetes, Terraform Kubernetes Operator, Terraform Module Registry, Vault HSM, Vault AWS, Vault GCP, Vault Azure, Consul AWS, Consul GCP, Consul Azure, Nomad Autoscaler, Terraform Cloud Agents, Vault SSH Secrets Engine, Vault Database Secrets Engine, Consul API Gateway, Vault Transit Secrets Engine, Terraform Cloud for Business, Vault Kubernetes Auth Method, Consul Terraform Sync, Nomad Autoscaling, Vault PKI Secrets Engine, Terraform Operator for Kubernetes, Consul Service Discovery, Vault Dynamic Secrets, Consul Network Infrastructure Automation, Vault Seal Wrap, Consul Connect, Vault Tokenization, Boundary Desktop Client, Boundary Web UI, Waypoint Runners, HCP Terraform Cloud Agent, Vault Enterprise Replication, Consul Enterprise Namespaces, Nomad CSI Plugins, Terraform Cloud Workspaces, Vault Monitoring and Audit Logging, Consul Observability, Boundary Sessions Management, Waypoint Plugins, Terraform Provider Development Program, Vault Plugin Framework, Consul Mesh Gateway
HashiCorp Terraform, HashiCorp Vault, HashiCorp Consul, HashiCorp Nomad, HashiCorp Vagrant, HashiCorp Packer, HashiCorp Boundary, HashiCorp Waypoint, Infrastructure as Code (IaC), Secret Management, Service Mesh, Service Discovery, Configuration Management, Cluster Scheduling, Machine Image Creation, Identity-Based Access, Application Deployment, HashiCorp Configuration Language (HCL), Secure Secrets Storage, Dynamic Secrets, Data Encryption, Zero Trust Security, Network Automation, Multi-Cloud Infrastructure Automation, Cloud Security, HashiCorp Cloud Platform, API Gateway, Provisioning Automation, Infrastructure Monitoring, HashiCorp Sentinel
Terraform, Packer, HashiCorp Vault, HashiCorp DevOps - HashiCorp SRE, HashiCorp Cloud Native - HashiCorp and Kubernetes, HashiCorp Cloud - HashiCorp Data Centers, HashiCorp GitHub - HashiCorp Open Source (), HashiCorp Development Tools (), HashiCorp Programming Languages (), HashiCorp APIs, HashiCorp and Concurrent Parallel Programming (), HashiCorp and Functional Programming (), HashiCorp and Microservices, HashiCorp Security - HashiCorp Security Breaches, HashiCorp Research, HashiCorp Networking, HashiCorp Data Science - HashiCorp DataOps - HashiCorp Databases, HashiCorp Artificial Intelligence (HashiCorp ML - HashiCorp MLOps, HashiCorp DL, HashiCorp AR - HashiCorp VR), HashiCorp IoT, HashiCorp Products - HashiCorp Services (), HashiCorp Operating Systems (), HashiCorp Software (), HashiCorp Hardware - HashiCorp Devices (), HashiCorp Support (), HashiCorp Media (), HashiCorp Communication (), HashiCorp Concepts (), HashiCorp acronyms (), HashiCorp Founders (), HashiCorp People (), HashiCorp Outline, HashiCorp History, HashiCorp Timeline, HashiCorp Subsidiaries (), HashiCorp Privacy (), HashiCorp Censorship (), HashiCorp Criticism (), HashiCorp Bibliography, HashiCorp Courses, HashiCorp Certification (), HashiCorp Glossary, HashiCorp Topics, HashiCorp Blog, HashiCorp Awesome List, Big Tech. (navbar_hashicorp)