Skip to content

Introduce dynamic provider sources#38405

Open
matejrisek wants to merge 14 commits intomainfrom
matejrisek/providers/dynamic_sources
Open

Introduce dynamic provider sources#38405
matejrisek wants to merge 14 commits intomainfrom
matejrisek/providers/dynamic_sources

Conversation

@matejrisek
Copy link
Copy Markdown
Member

@matejrisek matejrisek commented Apr 20, 2026

Introduce dynamic provider source and version - meaning we can now specify variables for required provider` sources and versions.

Example of what should be possible with these changes:

terraform {
  required_providers {
    tfcoremock = {
      source  = "${var.tfcoremock_src}"
      version = "${var.tfcoremock_ver}"
    }
  }
}

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

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

Potential future improvements:

  • We might get rid of the "legacy" string only resolution and treat everything as an expression to get rid of the old codepath. The reason we don't do it here is because there's a lot of tests failing that need to be changed for that. Not to cause more noise in this already sizable PR I decided not to include those changes here. Also we reduce blast radius by keeping the old behavior in case unforeseen issues occur in the new codepath.

Target Release

1.16.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

This type will hold expressions found in the source and version
variables of the required provider block.
If it encounters an expression holding a variable - the function will
now store that expression in the map that is part of the return contract
for the function.
Ignore the newly added map to make things compile.
Add tests later.
@matejrisek matejrisek changed the title Matejrisek/providers/dynamic sources Introduce dynamic provider sources Apr 21, 2026
@matejrisek matejrisek marked this pull request as ready for review April 23, 2026 10:20
@matejrisek matejrisek requested a review from a team as a code owner April 23, 2026 10:20
@matejrisek matejrisek requested review from dbanck and jbardin April 23, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant