pulumi / pulumi-converter-terraform

Apache License 2.0
9 stars 3 forks source link

`pulumi convert --from terraform` should automatically use "any TF provider" #186

Open lukehoban opened 1 month ago

lukehoban commented 1 month ago

When pulumi convert --from terraform runs into a provider it needs that is not available in the Pulumi Registry, it returns an error like:

Converting from terraform...

warning: failed to install provider "helm": could not find latest version for provider helm: 401 HTTP error fetching plugin from https://api.github.com/repos/pulumi/pulumi-helm/releases/latest

Now that we have support for Any Terraform Provider, the convert command could choose to do one of the following when it fails to find a provider it needs:

  1. At least - include a note on running pulumi package add terraform ... to the warning - so that users can easily discover how to handle this wwarning.
  2. Ideally - run this command automatically as a sub-step of the pulumi convert, that results in generating the local SDKs for the dependencies that are not available as part of the generated project.
brandonpollack23 commented 1 month ago

Working on this now, I have a draft in place that will consist of the following changes:

  1. pulumi-terraform-bridge add a call to return if there is a PulumiProviderName (in plugin_info.go)
  2. if there is none, we need ot convert/pull down the terraform version so read that in il/mapper.go in this project, and if there is one use the main.tf definitions to get the package name (slash and all) to pass back to pulumi/pulumi's mapper.
  3. In pulumi/pulumi when mapping from terraform specifically (convert command) make the installPlugin switch on whether this is native or not. If not use the bridge code (shared in package add) otherwise continue as normal