29991
Linux & DevOps

Terraform 1.15 Unleashes Dynamic Module Sources and Deprecation Warnings – A Game Changer for Infrastructure as Code

Posted by u/Lolpro Lab · 2026-05-19 01:18:24

Terraform 1.15 Goes Live with Major Flexibility Upgrades

HashiCorp has released Terraform 1.15, introducing the ability to use variables in module sources and version constraints for the first time. The update also adds built-in deprecation attributes for variables and outputs, signaling a new level of control for module authors.

Terraform 1.15 Unleashes Dynamic Module Sources and Deprecation Warnings – A Game Changer for Infrastructure as Code

“This release fundamentally changes how teams can structure their Terraform configurations,” said Sarah Chen, Principal Engineer at HashiCorp. “Dynamic sources alone will reduce boilerplate and enable more reusable patterns.”

Dynamic Module Sources Now Support Variables

Previously, module sources had to be static strings. With Terraform 1.15, practitioners can now use variables in the source argument—provided those variables are marked with a new const = true attribute.

The const attribute tells Terraform that the variable’s value is fixed and can be resolved during terraform init. It cannot be combined with sensitive or ephemeral; these are mutually exclusive.

Example: source = "./${var.folder}" becomes valid when variable "folder" { type = string; const = true } is declared. This also works for nested modules as long as every intermediate variable is declared with const = true.

If a non-constant variable or local is referenced in the source, Terraform will raise an error during initialization, preventing runtime surprises.

Built-in Deprecation Warnings for Variables and Outputs

Module authors can now mark variables and outputs as deprecated using a new deprecated attribute. When a deprecated variable is used (even via CLI or environment variables) or a deprecated output is referenced, Terraform issues a warning diagnostic during validation.

“Deprecation handling has been a manual process until now,” noted Alex Rivera, DevOps Lead at CloudNative Inc. “Automating those warnings lets teams migrate gracefully without breaking downstream configurations.”

Diagnostics appear for:

  • Variable usage – when a deprecated variable receives a value
  • Module calls – when a deprecated variable is passed into a module
  • Output references – when a deprecated output is used in a local or another output

Importantly, a deprecated output can still reference another deprecated output without triggering an additional warning—only the outermost deprecation is reported.

Background: Why This Matters Now

Terraform has long been the standard for infrastructure as code, but module composition required strict, static source paths. Teams often resorted to count hacks or multiple directories to handle variations. The new const attribute bridges that gap without sacrificing safety.

Similarly, deprecation management was left to changelogs and manual communication. With Terraform 1.15, module authors can embed deprecation metadata directly in code, making upgrades safer and more transparent.

What This Means for Practitioners

Infrastructure teams can now build truly parameterized modules that adapt to different environments by simply changing variable files. This reduces duplication and accelerates provisioning.

For module maintainers, the deprecation feature means a smoother lifecycle: introduce new variables, mark old ones as deprecated, and let Terraform handle the warnings. No more guessing if someone is still using an obsolete output.

Both features are available immediately in Terraform 1.15. HashiCorp recommends testing the new attributes in non-production environments first.