Skip to content

Use provider aliases from provider requirements #37172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/v1.13/BUG FIXES-20250526-222007.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: Add required providers aliases in graph to allow validation on standalone modules using aliases
time: 2025-05-26T22:20:07.711709913+02:00
custom:
Issue: "28490"
51 changes: 27 additions & 24 deletions internal/terraform/transform_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,35 +564,38 @@ func (t *ProviderConfigTransformer) transformSingle(g *Graph, c *configs.Config)
// access when passing around configuration and inheritance.
if path.IsRoot() && c.Module.ProviderRequirements != nil {
for name, p := range c.Module.ProviderRequirements.RequiredProviders {
if _, configured := mod.ProviderConfigs[name]; configured {
continue
}
for _, alias := range p.Aliases {
if _, configured := mod.ProviderConfigs[name]; configured {
continue
}

addr := addrs.AbsProviderConfig{
Provider: p.Type,
Module: path,
}
addr := addrs.AbsProviderConfig{
Provider: p.Type,
Module: path,
Alias: alias.Alias,
}

if _, ok := t.providers[addr.String()]; ok {
// The config validation warns about this too, but we can't
// completely prevent it in v1.
log.Printf("[WARN] ProviderConfigTransformer: duplicate required_providers entry for %s", addr)
continue
}
if _, ok := t.providers[addr.String()]; ok {
// The config validation warns about this too, but we can't
// completely prevent it in v1.
log.Printf("[WARN] ProviderConfigTransformer: duplicate required_providers entry for %s", addr)
continue
}

abstract := &NodeAbstractProvider{
Addr: addr,
}
abstract := &NodeAbstractProvider{
Addr: addr,
}

var v dag.Vertex
if t.Concrete != nil {
v = t.Concrete(abstract)
} else {
v = abstract
}
var v dag.Vertex
if t.Concrete != nil {
v = t.Concrete(abstract)
} else {
v = abstract
}

g.Add(v)
t.providers[addr.String()] = v.(GraphNodeProvider)
g.Add(v)
t.providers[addr.String()] = v.(GraphNodeProvider)
}
}
}

Expand Down