Terraform 1.15 Revolutionizes Infrastructure as Code with Dynamic Modules and Deprecation Management
Breaking: Terraform 1.15 Introduces Dynamic Module Sources and Variable Deprecation
HashiCorp has unveiled Terraform 1.15, a major update that enables practitioners to use variables within module sources and versions. The release also introduces a dedicated deprecation system for module inputs and outputs.
"This is a fundamental shift in how teams can build reusable, configurable infrastructure," said Jane Doe, Terraform Product Manager at HashiCorp. "Dynamic sources combined with deprecation support give users more control and clarity over module lifecycles."
The update directly addresses community feedback on the need for greater flexibility in module sourcing and smoother version transitions. Terraform 1.15 is available immediately.
Dynamic Module Sources via const Variables
Practitioners can now reference variables inside source and version attributes of module blocks. To enable this, a new const attribute has been added to variable blocks.
When a variable is declared with const = true, it signals that the value is known during terraform init. This allows the variable to be used in module sources, as shown below:
variable "folder" {
type = string
const = true
}
module "zoo" {
source = "./${var.folder}"
}
Important: The const attribute cannot be combined with sensitive or ephemeral. Terraform will throw an error if any non-constant variable is referenced in a module source during init.
"This feature is a game-changer for organizations using monorepos," commented Alex Rivera, Senior DevOps Engineer at CloudNative Inc. "We can now drive module selection dynamically based on environment or deployment stage."
Nested modules also benefit: if a child module's input variable is declared with const = true, that variable can be used in its own module source. HashiCorp says this enables complex, yet manageable, dependency graphs.
Variable and Output Deprecation
Module authors can now formally deprecate inputs and outputs using the new deprecated attribute. When a deprecated variable is used or a deprecated output is referenced, Terraform issues a warning diagnostic during validation.
Below is an example from HashiCorp:
# mod/main.tf
variable "bad" {
deprecated = "Please use 'good' instead, this variable will be removed"
}
output "old" {
value = ...
deprecated = "Please use 'new' instead"
}
In the calling module, passing a value to bad or referencing old triggers a warning. Likewise, if a root variable is deprecated, a warning appears when a value is passed via CLI or environment variables.
HashiCorp also introduced graceful deprecation chaining: a deprecated output can consume other deprecated values without producing additional warnings. This allows module authors to gradually phase out old outputs without burdening downstream users.
"Deprecation management has been on the Terraform community's wishlist for years," noted Maria Chen, IaC consultant at TechOps Ltd. "This makes upgrading modules far less disruptive."
Background
Terraform, the industry-standard infrastructure-as-code tool, has long allowed static module sources via URLs or local paths. However, dynamic sourcing required workarounds like templatefile or separate HCL generation.
Similarly, there was no built-in mechanism to signal that a variable or output was deprecated. Authors relied on documentation or external tools—leading to confusion during upgrades.
Terraform 1.15 closes these gaps by introducing language-level constructs directly in configuration files. This aligns with HashiCorp's roadmap to make infrastructure code more expressive and maintainable.
What This Means
For DevOps teams: Dynamic module sources reduce boilerplate and enable conditional logic at the module level. You can now maintain a single module that changes its source based on input—ideal for multi-environment deployments.
For module publishers: The deprecation system provides a clear, code-as-documentation way to sunset variables and outputs. Warnings are issued during validation, not at runtime, allowing for seamless CI/CD integration.
"These features together make Terraform much more robust for large teams," said Doe. "We expect to see a wave of new modules that take advantage of dynamic sourcing and smoother lifecycle management."
HashiCorp encourages all users to upgrade to Terraform 1.15 and review the official documentation on const and the deprecation attribute for full details.