HCL
HashiCorp Configuration Language: the block-based configuration syntax of Terraform files, which end in .tf.
In more detail
Files are made of blocks such as resource, variable and output, each with arguments written as name = value. Values in HCL may come from variables, modules and data sources that are unknown until plan time, which limits what a static scan can prove.
Examples
block_type "label" "another_label" {
argument = expression
}In Terraform: A block has a type, zero or more labels in quotes, and a body in braces; inside, each argument is a name, an equals sign and an expression. Blocks can nest, but the order of blocks and files means nothing, because Terraform works out the order from references. Strings use double quotes only, and comments start with #.Related terms
- Terraform — An infrastructure-as-code tool from HashiCorp that creates and changes cloud resources such as servers, networks and databases from configuration files.
- terraform plan — The command that compares configuration, state and reality and prints the actions needed to make them match, without changing anything.
- .tf file — A text file ending in .tf that holds Terraform configuration written in HCL.
- HCL block — A container in HCL written as a type, optional quoted labels and a body in braces, such as resource "local_file" "greeting" { }.
- HCL argument — A name, an equals sign and an expression inside a block, such as filename = "hello.txt", which sets one value.
- Terraform expression — Anything that produces a value on the right of an equals sign: a literal, a reference, a function call, a for expression or a conditional.
Taught in
- Enforcing OPA Guardrails on Terraform Plan Payloads — Cloud Security & DevSecOps Engineering
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Writing Your First Configuration In HCL — Infrastructure as Code with Terraform
- Parameterising With Input Variables — Infrastructure as Code with Terraform
- Return Values: Outputs And Locals — Infrastructure as Code with Terraform
- Functions And Expressions In HCL — Infrastructure as Code with Terraform
- Infrastructure As Code, And One Workflow For Every Platform — HashiCorp Terraform Associate (004) Exam Prep
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Versions, The Lock File And Provider Aliases — HashiCorp Terraform Associate (004) Exam Prep
- State: Terraform's Memory Of What It Built — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Custom Conditions: Validation, Pre And Postconditions, Checks — HashiCorp Terraform Associate (004) Exam Prep
- Where Modules Come From — HashiCorp Terraform Associate (004) Exam Prep
- Module Versions: Pin, Upgrade, Re-Initialise — HashiCorp Terraform Associate (004) Exam Prep