Primitive values and null
Start with four kinds of values
A value is a piece of information in a configuration. Its type tells Terraform how that information can be used. Think of a service name, a capacity, a switch and an unset setting. The following lines are separate expressions to inspect on paper, not a complete .tf file. Enter each separately in an approved local console if available. All results in this chapter are predictions, not recorded runs.
"catalog"32.5falsenullThe first is text (string), the next two are both number, the fourth is bool, and the last represents absence. A literal is written directly in the configuration, rather than obtained from another value.
Text, numbers and switches
Quotes matter. "3" is text even if it looks numeric, and "false" is not a Boolean switch. Terraform has one primitive numeric type, not separate integer and floating-point types for input constraints. A provider can still require an integer or impose its own range. Do not assume JavaScript numeric limits or unlimited exact decimal arithmetic: precision, rounding and conversion at external API boundaries can matter. For capacities that must be whole numbers, validate that requirement separately.
For a fictional service, the name might be "catalog", the replica count 3 and monitoring true. These are inputs to a design; they do not create a service on their own.
Inspect types without provisioning
Use the empty, version-pinned console fixture described in lab-fixtures/value-types/README.md. After checking the approved CLI and initializing that isolated directory, enter terraform console. Type one line at a time; the type function is a diagnostic available in the console, not an ordinary configuration expression.
type("08")type(8)type(true)Expected types, in order: string, number, bool. The leading zero in the first expression is part of the text, which is useful for identifiers that are not quantities. Exit with exit before running other commands that need the state lock.
Absence is not an empty value
Consider these separate literal expressions:
""0false[]{}nullAn empty string, zero, false, an empty tuple and an empty object are all concrete values. Null instead expresses absence. In a resource argument, assigning null normally requests omission; an optional argument may then use a default, while a mandatory one can be rejected. Check the actual argument contract rather than assuming a default exists. Inside an object, an attribute with a null value is not the same structure as an object without that attribute. Optional attribute rules can normalize the distinction later.
Common mistakes
Do not use the string "null" to omit a setting. Do not replace every missing value with zero: zero replicas and an unspecified replica count can mean different things. Do not assume a number always fits a provider field. Terraform may perform conversions in typed contexts, but explicitly deciding what information a field represents makes the configuration easier to review.
Practice and next step
Classify "07", 7, true, "" and null. Then explain why zero is not a substitute for absence. Next, combine values into inventories with collection and structural types. Related reference: Primitive values and null.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Primitive values and null — knowledge check
Check the concepts and decisions introduced in this lesson.
Which expression is a string?
Which two values have the number type?
What does false represent?
What can happen when a mandatory resource argument is null?
Where is type("08") valid for inspecting a value?