5 Essential Updates in Terraform 1.15 You Should Know
Terraform 1.15 has arrived with powerful new features that streamline infrastructure management. This release introduces dynamic module sources using the const attribute, deprecation support for variables and outputs, and smarter diagnostic warnings. Whether you're a module author or a practitioner, these updates help you write cleaner, more maintainable code. Let's dive into the top five changes you need to know.
1. Dynamic Module Sources with const Variables
Previously, module sources couldn't use variables because terraform init runs before variable resolution. With Terraform 1.15, you can now mark a variable as const = true, allowing it to be evaluated at initialization. This const attribute accepts only a boolean value, and it cannot be combined with sensitive or ephemeral. Here’s a simple example:
variable "folder" {
type = string
const = true
}
module "zoo" {
source = "./${var.folder}"
}
This capability extends to nested modules, as long as their input variables are explicitly declared with const = true. Terraform will raise an error during init if you reference a non-const variable or a local in the source path. It's a safe, predictable way to parameterize module origins.
2. Variable Deprecation for Module Authors
Module authors often need to phase out old variables. Terraform 1.15 introduces the deprecated attribute for variable blocks. When a deprecated variable is used, a warning diagnostic appears during validation. For example:
variable "bad" {
deprecated = "Please use 'good' instead; this variable will be removed."
}
If someone passes a value to bad via CLI arguments, environment variables, or Terraform Cloud, they'll see the warning. This helps ensure no lingering old values remain in your environment. The warning is emitted on any usage, making it easy to track dependencies and plan migrations.
3. Output Deprecation with Graceful Propagation
Outputs can also be marked as deprecated using the same deprecated attribute. When a module’s output is deprecated, any reference to it triggers a diagnostic warning. For module authors, this is a gentle way to signal that an output is being replaced. Importantly, you can still pass a deprecated output into another deprecated output without causing duplicate warnings. Example:
# mod/main.tf
output "old" {
value = "some_value"
deprecated = "Please use 'new' instead."
}
# main.tf
module "myModule" {
source = "./mod"
}
output "ancient" {
value = module.myModule.old
deprecated = "Please stop using this."
}
Only top-level references to a deprecated output produce warnings; if you wrap it in another deprecated output, the user sees a single warning for the outermost one. This reduces noise while still encouraging migration.
4. Comprehensive Diagnostic Warnings
Terraform 1.15 improves diagnostics for deprecated resources, variables, and outputs. When you reference a deprecated resource, a warning appears during validation. The same applies when you pass a value to a deprecated variable or read a deprecated output. For instance, consider this combined example:
variable "root" {
deprecated = "This should no longer be used."
}
module "myModule" {
source = "./mod"
bad = "not good" # 'bad' is deprecated in the module
}
locals {
moduleUsage = module.myModule.old # 'old' is deprecated
}
This code produces three warnings: one for var.root if a value is passed, one for module.myModule.bad, and one for locals.moduleUsage. The warnings are clear and actionable, helping you track every deprecated element in your configuration.
5. Gradual Deprecation Management for Outputs
Module authors can now manage deprecation in stages. The new behavior allows deprecated outputs to be consumed without cascading multiple warnings. If a module output is deprecated, you can still use it in your own deprecated output, and only the top-level deprecated output triggers a warning. This means you can deprecate an output internally before exposing the deprecation to consumers. It gives you flexibility to update your module's interface without breaking downstream configurations immediately. Combined with the variable deprecation, Terraform 1.15 provides a robust toolkit for lifecycle management.
These five updates make Terraform 1.15 a must-upgrade for teams practicing Infrastructure as Code. Dynamic sources reduce duplication, deprecation warnings improve communication, and the diagnostic system keeps your deployments clean. Try them today and see how they simplify your workflows.
Related Articles
- Exploring the Feasibility of 1GB Transparent Huge Pages in Linux
- Major Security Patches Issued Across Linux Distributions: Urgent Updates Required
- QLNX Linux RAT: How It Steals Developer Credentials and Compromises the Software Supply Chain
- Navigating the Latest Security Patches: A Roundup of Linux Distributions
- Memory Management Overhaul Proposed: 'Policy Groups' Aim to Fix Kernel Cgroup Limitations
- Exploring Fedora Atomic Desktops 44: Key Questions Answered
- Linux Security, AI Developments, and More: Your Questions Answered
- A Complete Guide to Adding a Directory to Your PATH