8 Game-Changing Features in Terraform 1.15 You Need to Know
Terraform 1.15 brings significant enhancements that improve module flexibility and lifecycle management. This release introduces dynamic module sources and structured deprecation workflows, making infrastructure-as-code more adaptable and maintainable. Below, we break down eight key features you should understand.
1. Dynamic Module Sources
With Terraform 1.15, you can now use variables directly in module source paths and version references. Previously, module sources were static and couldn't leverage simple variable interpolation. Now, by combining the new const attribute (see item 2) with the source argument, you can create reusable configurations that adapt to different environments without duplicating module blocks.
2. The New const Attribute for Variables
Terraform 1.15 introduces a const attribute for variable blocks. Setting const = true marks a variable as a compile-time constant that can be resolved during terraform init. This is critical for dynamic sources. Note that const is mutually exclusive with sensitive and ephemeral attributes. For example:
variable "folder" {
type = string
const = true
}
The value of such a variable must be a literal string or a direct reference to another const variable—no runtime expressions.
3. Using const Variables in Module Sources
The primary use case for const variables is in module source definitions. You can now write:
module "zoo" {
source = "./${var.folder}"
}
This works because var.folder is resolved before initialization. The same applies to version constraints. During terraform init, Terraform validates that the source path actually exists, and throws an error if you accidentally reference a non-const variable or a local value.
4. Nested Modules and const Support
Dynamic sources aren't limited to top-level modules. In Terraform 1.15, nested modules, submodules, and even modules called from other modules can use const variables—provided those variables are explicitly declared with const = true in each module's variables file. This allows you to build hierarchies of modules that share a common, init-time configuration.
5. Variable and Output Deprecation
Managing module evolution is easier with the new deprecated attribute for variable and output blocks. Module authors can now mark an input variable or output as deprecated, providing a message that guides users to a replacement:
variable "bad" {
deprecated = "Please use 'good' instead, this variable will be removed"
}
When a user assigns a value to a deprecated variable (or references a deprecated output), Terraform emits a warning diagnostic during validation, not just plan/apply.
6. How Deprecation Warnings Work
Terraform emits deprecation warnings for three common scenarios. First, if a root variable is deprecated and a value is supplied via CLI, environment variable, or TFC workspace. Second, when a module call passes a value to a deprecated input variable. Third, when any configuration references a deprecated output or resource. This helps users identify and clean up legacy usage before removal.
7. Graduated Deprecation for Outputs
Terraform 1.15 allows deprecation to cascade without redundant warnings. If a module output is deprecated and a higher-level module re-exposes that output as deprecated, only the highest-level deprecation warning is emitted. This enables a gradual migration path:
# mod/outputs.tf
output "old" {
value = ...
deprecated = "Use new"
}
# main.tf
output "ancient" {
value = module.myModule.old
deprecated = "Stop using this"
}
Only one warning per reference chain appears, keeping output clean.
8. Practical Example of Deprecation Usage
Consider a module with a deprecated variable and output. In main.tf:
variable "root" {
deprecated = "This should no longer be used."
}
module "myModule" {
source = "./mod"
bad = "not good"
}
locals {
moduleUsage = module.myModule.old
}
Terraform will emit three diagnostics: one for the root variable (if a value is passed), one for the module input bad (since the variable inside the module is deprecated), and one for locals.moduleUsage (because old output is deprecated). This transparency helps both module authors and consumers negotiate deprecation gracefully.
These eight features make Terraform 1.15 a must-upgrade for teams managing complex module ecosystems. Dynamic sources reduce boilerplate, and structured deprecation ensures smooth transitions. Upgrade today to take advantage of these improvements.
Related Articles
- Linux News Roundup: AI in Ubuntu, New Projects Folder, and Open Source Milestones
- Streamlining Linux Kernel Configuration with Kconfirm: A Practical Guide
- How to Install or Upgrade to Fedora Asahi Remix 44 on Apple Silicon Macs
- Everything You Need to Know About Ubuntu 26.04 LTS 'Resolute Raccoon'
- Powering Hyperscale Efficiency: Meta’s AI-Driven Approach to Capacity Optimization
- Fedora Atomic Desktops in Fedora 44: Key Updates and Q&A
- Mozilla’s For-Profit Arm Unveils Thunderbolt: Open-Source ‘Sovereign AI’ for Enterprises
- European Sovereign Tech Fund Boosts KDE’s Desktop Security and Infrastructure