Can you use variables in the backend block?
IntermediateConceptVariables, Locals, Outputs and Types
Answer
No. Backend configuration is read before variables are evaluated, so var. references fail. Use partial configuration with terraform init -backend-config=... and a per-environment file instead. OpenTofu 1.8 added early evaluation, allowing variables and locals in backend and module source arguments.
More on Variables, Locals, Outputs and Types
How do you declare an input variable?BeginnerIn what order does Terraform load variable values?BeginnerHow do you define an output and what is it for?BeginnerWhat is the difference between locals and variables?BeginnerWhat are the primitive types in Terraform?BeginnerHow do list, set and map differ?Intermediate