variables.tf and terraform.tfvars. It also includes a consolidated example showing how several types are used together in an azurerm_storage_account resource.
For additional reading, see the Terraform docs on input variables: https://www.terraform.io/language/values/variables
Common Terraform variable data types

Short notes on selected types
- map: Use
map(string)ormap(number)when values share a single type; access entries viavar.my_map["key"]. - object: Use objects to group related attributes and access them with
var.obj.attr. - tuple: Useful for fixed-position data such as
[ "log", 30 ]where positions convey meaning. - any: Avoid in production code; it defeats type checking and can hide configuration errors.
Prefer specific types (string, number, bool, list, map, object) over
any whenever possible. Strong typing enables Terraform to validate inputs and catch errors early.
Consolidated example
The example below demonstrates defining variables invariables.tf, consuming them in main.tf, and providing runtime values in terraform.tfvars.
terraform.tfvars (override defaults or provide runtime values):
storage_account_nameis declared as astring.https_onlyis aboolwith a default oftrue; you can override it interraform.tfvars.tagsis amap(string)used for tagging resources.storage_configis anobjectgrouping related attributes accessed viavar.storage_config.location,var.storage_config.account_tier, etc.
any unless flexibility is essential.
Be cautious when using
any. It disables type checking and can make debugging harder. Prefer explicit types for production code.- Terraform: Input Variables — https://www.terraform.io/language/values/variables
- Terraform: Types — https://www.terraform.io/language/types