Example: In Azure, I'm deploying multiple resource groups, managed disks, network interfaces, etc, all in the same region.
I want to declare a "region" primitive (a "constant"), which all these resources will reference. Which of those is following convention?
a) variables.tf:
variable "region" {
type = string
default = "a-place"
}
b) locals.tf
locals {
region = "a-place"
}
Naturally, I would choose to declare it as a local. I would only use a variable if I expect a value to come (or be overridden) from environment variables, command line, or if I were creating a module.
However, I haven't seen local being used for "declaring constants" in any examples, which makes me think that a convention exists to use locals with very limited scope (e.g. mainly for creating structures which can be of use with count and for_each constructions).
Covering my back before someone flags this as opinion based: I'm asking what the convention is, not what your opinion is that the convention should be.
Follow-up question: Would the answer be any different if this example covered IP addresses, resource name prefixes, etc. instead of region? (does the convention only cover particular fields?)