Numbers, Booleans, and Null Values
What you'll learn: How to work with HCL's primitive data types for numeric values, true/false logic, and representing absence of value.
The Basics of Primitive Types
After strings, HCL's next fundamental building blocks are numbers, booleans, and null values. These primitive data types let you express quantities, make logical decisions, and explicitly indicate when something has no value.
Numbers
HCL supports both integers (whole numbers) and floating-point numbers (decimals). You write them directly without quotes:
instance_count = 3
cpu_threshold = 80.5
port = 443
Think of numbers like dials and counters in your infrastructure—how many servers to create, what percentage triggers an alarm, which port to use.
Booleans
Booleans represent true/false conditions. Use the literal keywords true or false (lowercase, no quotes):
enable_monitoring = true
public_access = false
Booleans act like switches: features that are either on or off, enabled or disabled.
Null Values
The null keyword explicitly represents "no value" or "not set." It's different from an empty string or zero:
backup_retention_days = null # explicitly unset
Think of null as leaving a form field intentionally blank versus writing "0" or "" in it—they mean different things to Terraform.
Why These Matter
These primitives control your infrastructure's behavior: how many resources to create, whether features are enabled, and what values to pass (or not pass) to cloud APIs. Unlike strings, numbers can be used in arithmetic, and booleans drive conditional logic.
Key Takeaway: HCL's primitive types—numbers (integers and decimals), booleans (true/false), and null—are the building blocks for expressing infrastructure parameters, feature toggles, and intentionally absent values.