Merge pull request #26871 from hashicorp/alisdair/fix-provider-lookup-local-name-mismatch
configs: Fix provider lookup local name mismatch
This commit is contained in:
commit
fce77f29da
|
@ -66,8 +66,12 @@ func (r *Resource) Addr() addrs.Resource {
|
|||
// config addr if an explicit "provider" argument was not provided.
|
||||
func (r *Resource) ProviderConfigAddr() addrs.LocalProviderConfig {
|
||||
if r.ProviderConfigRef == nil {
|
||||
// If no specific "provider" argument is given, we want to look up the
|
||||
// provider config where the local name matches the implied provider
|
||||
// from the resource type. This may be different from the resource's
|
||||
// provider type.
|
||||
return addrs.LocalProviderConfig{
|
||||
LocalName: r.Provider.Type,
|
||||
LocalName: r.Addr().ImpliedProvider(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,14 @@ For example, to correlate with indices of a referring resource, use:
|
|||
aws_instance.count[count.index]
|
||||
- Unsupported attribute: This object has no argument, nested block, or exported attribute named "foo".`,
|
||||
},
|
||||
{
|
||||
"boop_instance.yep",
|
||||
``,
|
||||
},
|
||||
{
|
||||
"boop_whatever.nope",
|
||||
`Invalid resource type: A managed resource type "boop_whatever" is not supported by provider "registry.terraform.io/foobar/beep".`,
|
||||
},
|
||||
}
|
||||
|
||||
cfg := testModule(t, "static-validate-refs")
|
||||
|
@ -62,6 +70,12 @@ For example, to correlate with indices of a referring resource, use:
|
|||
"aws_instance": {},
|
||||
},
|
||||
},
|
||||
addrs.MustParseProviderSourceString("foobar/beep"): {
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
// intentional mismatch between resource type prefix and provider type
|
||||
"boop_instance": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
boop = {
|
||||
source = "foobar/beep" # intentional mismatch between local name and type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_instance" "no_count" {
|
||||
}
|
||||
|
||||
resource "aws_instance" "count" {
|
||||
count = 1
|
||||
}
|
||||
|
||||
resource "boop_instance" "yep" {
|
||||
}
|
||||
|
||||
resource "boop_whatever" "nope" {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue