pulumi / pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
https://www.pulumi.com/docs/reference/clouds/kubernetes/
Apache License 2.0
407 stars 117 forks source link

TF Converter for Helm Release #2744

Open GeoffMillerAZ opened 10 months ago

GeoffMillerAZ commented 10 months ago

What happened?

When the import tool is used on a terraform state file the import file is created for resources of type: helm:index:release and one must replace all of these strings with the appropriate string: kubernetes:helm.sh/v3:Release.

Example

pulumi import --from terraform terraform.tfstate

results in:

{
    "resources": [
        {
            "type": "helm:index:release",
            "name": "myrelease",
            "id": "myrelease",
            "logicalName": "myrelease"
        }
    ]
}

Should be:

{
    "resources": [
        {
            "type": "kubernetes:helm.sh/v3:Release",
            "name": "myrelease",
            "id": "myrelease",
            "logicalName": "myrelease"
        }
    ]
}

Output of pulumi about

CLI
Version 3.99.0 Go Version go1.21.5 Go Compiler gc

Plugins NAME VERSION gcp 7.2.1 kubernetes 4.5.4 nodejs unknown random 4.14.0 std 1.4.0 time 0.0.16

Host
OS darwin Version 14.2.1 Arch arm64

This project is written in nodejs: executable='/usr/local/bin/node' version='v18.18.0'

...

Found no pending operations associated with dev

Backend
Name pulumi.com URL https://app.pulumi.com/GeoffMillerAZ User GeoffMillerAZ Organizations GeoffMillerAZ Token type personal

Dependencies: NAME VERSION @pulumiverse/time 0.0.16 @types/node 14.18.63 typescript 4.9.5 @pulumi/gcp 7.2.1 @pulumi/kubernetes 4.5.4 @pulumi/pulumi 3.95.0 @pulumi/random 4.14.0 @pulumi/std 1.4.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

EronWright commented 4 months ago

Here's an update on this issue, it is because the Kubernetes provider simply doesn't have support for converting a helm_release TF resource to a kubernetes:helm.sh/v3:Release Pulumi resource. I'm treating this ticket as a request to add support. Here's an outline of the tasks:

  1. Enhance the provider to return mapping data for the helm TF provider. The engine calls GetMappings on the provider to discover which TF providers it has mappings for, and it should return kubernetes and helm. It then calls GetMapping for each.
  2. Create a mapping for the helm_release resource, such that the attributes on the TF side are mapped to the inputs on the Pulumi side.
  3. Write some tests to verify that attributes are converted as expected and that import works as expected.
EronWright commented 2 months ago

It appears that TF conversion is not totally practical, because the schema of helm.sh/v3:Release is considerably different from the TF helm_release. The converter would need to transform the configuration beyond its current abilities, which I believe is focused on supporting bridged providers (where the schema is presumed to be highly compatible).

I recommend that we close this as won't fix for now. Thoughts?

Zaid-Ajaj commented 1 month ago

It appears that TF conversion is not totally practical, because the schema of helm.sh/v3:Release is considerably different from the TF helm_release. The converter would need to transform the configuration beyond its current abilities, which I believe is focused on supporting bridged providers (where the schema is presumed to be highly compatible).

@EronWright it's true that coming up with a dummy tf mapping for the Release is not sufficient because the shape of the schemas are quite different from tf to Pulumi.

That said, the converter can always operate on the AST level and map the configuration as close as possible to what Pulumi expects. I've raised https://github.com/pulumi/pulumi-converter-terraform/pull/198 to address the issue