Terraform 1.15: 6 Essential Features to Boost Your Infrastructure

By

Terraform 1.15 delivers powerful enhancements that streamline module management and deprecation handling. From dynamic module sources using variables to a refined deprecation system for variables and outputs, this release empowers practitioners with greater flexibility and control. Here are six key features you need to know about.

1. Dynamic Module Sources

Terraform 1.15 now allows variables in module sources and versions during initialization. Previously, module sources were static strings. With this update, you can define a variable marked as const = true and reference it directly in a module's source attribute. This enables more flexible and parameterized configurations, ideal for multi‑environment setups or reusable modules that need to pull from different locations based on input variables. For example, a folder–based source can be dynamically set without hard‑coding paths.

Terraform 1.15: 6 Essential Features to Boost Your Infrastructure

2. Introducing the const Attribute

The new const attribute is a boolean flag that signals whether a variable is safe to use during terraform init. When set to true, the variable becomes constant, allowing interpolation in module sources and versions. However, const is mutually exclusive with sensitive and ephemeral, ensuring that only non‑secret, unchanging values are used during initialization. This prevents dynamic or confidential data from appearing in module source paths, preserving stability and security.

3. Using const in Module Sources

To leverage dynamic sources, declare a variable with const = true and reference it in the module source. Example:

variable "folder" {
  type  = string
  const = true
}

module "zoo" {
  source = "./${var.folder}"
}

This pattern extends to nested modules, provided their input variables are also declared with const = true. It offers a clean way to parameterize module sources without compromising initialization integrity. The variable’s value is effectively frozen at plan time.

4. Error Handling for Dynamic Sources

Terraform will report an error during init if you reference anything other than a constant variable (e.g., a local or a regular variable) in a module source. This safeguard ensures that module sources remain deterministic and free from post‑initialization changes. By enforcing this constraint, Terraform helps you avoid surprising path changes that could break your configuration. Always use the const attribute for any variable intended to be used in module sources.

5. Deprecation for Variables and Outputs

Module authors can now mark variables and outputs as deprecated using the deprecated attribute. When a deprecated variable is assigned a value, or a deprecated output is referenced, Terraform issues a warning diagnostic during validate. For example:

variable "bad" {
  deprecated = "Please use 'good' instead"
}

output "old" {
  value = ...
  deprecated = "Use 'new' instead"
}

This helps users transition away from outdated interfaces without breaking existing configurations. Warnings appear for variable assignments (via CLI, environment, etc.) and direct references to deprecated outputs or resources.

6. Gradual Deprecation with Deprecated Outputs

Terraform 1.15 allows deprecated outputs to reference other deprecated values without causing cascading warnings. This enables module authors to phase out multiple outputs systematically. A diagnostic warning is emitted only when the deprecated output is actually consumed by a module caller, not when it merely wraps another deprecated entity. This reduces false positives while maintaining clear deprecation signals. For instance, you can deprecate an output that internally uses another deprecated output; only the outermost reference triggers a warning.

These six features make Terraform 1.15 a must‑upgrade for teams seeking greater flexibility in module sourcing and a smoother deprecation workflow. Dynamic sources empower adaptable configurations, while the deprecation system offers a clear, gradual migration path. Start exploring these capabilities today to future‑proof your infrastructure code.

Related Articles

Recommended

Discover More

Safari Technology Preview 243: Key Updates and Fixes Explained10 Key Insights on the EUR Stablecoin Surge to a $774M All-Time HighGrafana Launches AI-Powered Assistant to Instantly Diagnose Slow Database QueriesSafari Technology Preview 241: New Features and Bug Fixes ExplainedBraze CTO Jon Hyman Reveals How He Engineered an AI-First Transformation in Months, Not Years