backport of commit 82889ae987

pull/37715/head
James Bardin 8 months ago
parent 129d7bd4d4
commit e2adb55fed

@ -30,7 +30,10 @@ func TestContext2Plan_queryList(t *testing.T) {
instanceTypes := []string{"ami-123456", "ami-654321", "ami-789012"}
madeUp := []cty.Value{}
for i := range len(instanceTypes) {
madeUp = append(madeUp, cty.ObjectVal(map[string]cty.Value{"instance_type": cty.StringVal(instanceTypes[i])}))
madeUp = append(madeUp, cty.ObjectVal(map[string]cty.Value{
"instance_type": cty.StringVal(instanceTypes[i]),
"id": cty.StringVal(fmt.Sprint(i)),
}))
}
ids := []cty.Value{}
@ -1004,6 +1007,10 @@ func getListProviderSchemaResp() *providers.GetProviderSchemaResponse {
Computed: true,
Optional: true,
},
"id": {
Type: cty.String,
Computed: true,
},
},
},
"test_child_resource": {

@ -977,10 +977,17 @@ func (n *NodePlannableResourceInstance) generateResourceConfig(ctx EvalContext,
if diags.HasErrors() {
return cty.DynamicVal, diags
}
schema := providerSchema.SchemaForResourceAddr(n.Addr.Resource.Resource)
// the calling node may be a list resource, in which case we still need to
// lookup the schema for the corresponding managed resource for generating
// configuration.
managedAddr := n.Addr.Resource.Resource
managedAddr.Mode = addrs.ManagedResourceMode
schema := providerSchema.SchemaForResourceAddr(managedAddr)
if schema.Body == nil {
// Should be caught during validation, so we don't bother with a pretty error here
diags = diags.Append(fmt.Errorf("provider does not support resource type for %q", n.Addr))
diags = diags.Append(fmt.Errorf("provider does not support resource type for %q", managedAddr))
return cty.DynamicVal, diags
}

Loading…
Cancel
Save