2020-12-09 15:31:34 +00:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/plugin"
|
|
|
|
"github.com/hashicorp/terraform/plugin/discovery"
|
|
|
|
)
|
|
|
|
|
2021-02-09 13:53:57 +00:00
|
|
|
func NewGRPCProvider(meta discovery.PluginMeta) (*plugin.GRPCProvider, error) {
|
2020-12-09 15:31:34 +00:00
|
|
|
client := Client(meta)
|
|
|
|
// Request the RPC terraformProvider so we can get the provider
|
|
|
|
// so we can build the actual RPC-implemented provider.
|
|
|
|
rpcClient, err := client.Client()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
raw, err := rpcClient.Dispense(plugin.ProviderPluginName)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
GRPCProvider := raw.(*plugin.GRPCProvider)
|
|
|
|
GRPCProvider.PluginClient = client
|
|
|
|
|
|
|
|
return GRPCProvider, nil
|
|
|
|
}
|