HCL in depth
HCL is a configuration language that’s used by several HashiCorp tools, including Terraform, to define and manage IaC.
HCL is designed to be easy to read and write for both humans and machines. It uses a simple syntax that is similar to JSON but with a more relaxed structure and support for comments. HCL files typically have an .hcl
or .tf
file extension.
HCL uses curly braces to define blocks of code, and each block has a label that identifies its type. Within each block, we define attributes using a key-value
syntax, where the key is the attribute name and the value is the attribute value. We can also define objects using curly braces, as shown in the example with the tags
object.
Variables
In HCL, variables are defined using the variable
block. Here’s an example of how to define a variable in HCL:
variable "region" { type = string default = "eu-central-1" }
In this example, we define a variable...