diff --git a/pkg/tfbridge/provider.go b/pkg/tfbridge/provider.go index 13432919c..24f07a996 100644 --- a/pkg/tfbridge/provider.go +++ b/pkg/tfbridge/provider.go @@ -1253,15 +1253,20 @@ func (p *Provider) Cancel(ctx context.Context, req *pbempty.Empty) (*pbempty.Emp func (p *Provider) GetMapping( ctx context.Context, req *pulumirpc.GetMappingRequest) (*pulumirpc.GetMappingResponse, error) { - info := MarshalProviderInfo(&p.info) - mapping, err := json.Marshal(info) - if err != nil { - return nil, err + if req.Key == "tf" { + info := MarshalProviderInfo(&p.info) + mapping, err := json.Marshal(info) + if err != nil { + return nil, err + } + return &pulumirpc.GetMappingResponse{ + Provider: p.info.Name, + Data: mapping, + }, nil } - return &pulumirpc.GetMappingResponse{ - Provider: p.info.Name, - Data: mapping, - }, nil + + // An empty response is valid for GetMapping, it means we don't have a mapping for the given key + return &pulumirpc.GetMappingResponse{}, nil } func initializationError(id string, props *pbstruct.Struct, reasons []string) error { diff --git a/pkg/tfgen/pluginHost.go b/pkg/tfgen/pluginHost.go index a2e076f8a..b3c3a4b81 100644 --- a/pkg/tfgen/pluginHost.go +++ b/pkg/tfgen/pluginHost.go @@ -55,12 +55,15 @@ func (p *inmemoryProvider) GetSchema(version int) ([]byte, error) { } func (p *inmemoryProvider) GetMapping(key string) ([]byte, string, error) { - info := tfbridge.MarshalProviderInfo(&p.info) - mapping, err := json.Marshal(info) - if err != nil { - return nil, "", err + if key == "tf" { + info := tfbridge.MarshalProviderInfo(&p.info) + mapping, err := json.Marshal(info) + if err != nil { + return nil, "", err + } + return mapping, p.info.Name, nil } - return mapping, p.info.Name, nil + return nil, "", nil } func (p *inmemoryProvider) GetPluginInfo() (workspace.PluginInfo, error) {