ambitious-crayon-4360
08/13/2024, 11:44 AM[1/26] terraform_provider_name (terraform-provider-name): netappontap
[2/26] terraform_provider_org (terraform-providers): netapp
[3/26] terraform_provider_source (<http://github.com/netapp/terraform-provider-netappontap|github.com/netapp/terraform-provider-netappontap>): <http://github.com/netapp/terraform-provider-netapp-ontap|github.com/netapp/terraform-provider-netapp-ontap>
[4/26] terraform_provider_version_or_commit (0.0.0): 1.1.2
[5/26] terraform_provider_module (<http://github.com/netapp/terraform-provider-netappontap|github.com/netapp/terraform-provider-netappontap>): <http://github.com/netapp/terraform-provider-netapp-ontap|github.com/netapp/terraform-provider-netapp-ontap>
[6/26] terraform_provider_package_name (netappontap): internal/provider
[7/26] Select terraform_sdk_version
1 - 1
2 - 2
3 - plugin-framework
Choose from [1/2/3] (1): 3
...
[23/26] go_version (1.22.5):
...
According to the blog I also changed the ~/pulumi-netappontap/provider/shim/shim.go to:
package shim
import (
"<http://github.com/netapp/terraform-provider-netapp-ontap/internal/provider|github.com/netapp/terraform-provider-netapp-ontap/internal/provider>"
tfpf "<http://github.com/hashicorp/terraform-plugin-framework/provider|github.com/hashicorp/terraform-plugin-framework/provider>"
)
func NewProvider() tfpf.Provider {
return provider.New("dev")()
}
In step 1/26 I initially had for terraform-provider-name "netapp-ontap"
cookiecutter then fails on an assertion:
ERROR: netapp-ontap IS NOT a valid terraform provider name!
ERROR: Stopping generation because pre_gen_project hook script didn't exit successfully
But with the custom terraform-provider-name "netappontap", the process fails at make tfgen:
1-alpha.1723480192+a6d32fc5" <http://github.com/pulumiverse/pulumi-netappontap/provider/cmd/pulumi-tfgen-netappontap)|github.com/pulumiverse/pulumi-netappontap/provider/cmd/pulumi-tfgen-netappontap)>
$/dev-projects/pulumi-netappontap/bin/pulumi-tfgen-netappontap schema --out provider/cmd/pulumi-resource-netappontap
panic: fatal: An assertion has failed: Invalid snake case name netapp-ontap_cluster_licensing_license_resource. Does not start with netappontap
I did a 'hack' with a custom regexp in the pre_gen_project hook script. But I think that's a bad idea:
In ~/.cookiecutters/pulumi-tf-provider-cookiecutter/hooks/pre_gen_project.py:
PROVIDER_NAME_REGEX = r"^[-a-zA-Z0-9]+$"
I get further, but with a different error message:
(vcoockiecutter) :~/dev-projects/pulumi-netapp-ontap$ make tfgen
[ -x $/.pulumi/bin/pulumi ] || curl -fsSL <https://get.pulumi.com> | sh
pulumi plugin install resource random 4.3.1
(cd provider && go build -o $/dev-projects/pulumi-netapp-ontap/bin/pulumi-tfgen-netapp-ontap -ldflags "-X <http://github.com/pulumiverse/pulumi-netapp-ontap/provider/pkg/version.Version=0.0.1-alpha.1723229264+1efcb411|github.com/pulumiverse/pulumi-netapp-ontap/provider/pkg/version.Version=0.0.1-alpha.1723229264+1efcb411>" <http://github.com/pulumiverse/pulumi-netapp-ontap/provider/cmd/pulumi-tfgen-netapp-ontap)|github.com/pulumiverse/pulumi-netapp-ontap/provider/cmd/pulumi-tfgen-netapp-ontap)>
cmd/pulumi-tfgen-netapp-ontap/main.go:18:8: missing import path
make: *** [Makefile:49: tfgen] Error 1
To 'fix' that, I changed the import path in the two main.go files:
from: netapp-ontap
to: netappontap
tfgen gets through, but with 109 errors afterwards in the mod.go file.
But in the end, things still go wrong with the created Python SDK.
Import the python package:
>>> imnport pulumiverse_netapp-ontap
File "<stdin>", line 1
imnport pulumiverse_netapp-ontap
^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax
And
>>> pulumiverse_netapp = __import__('pulumiverse_netapp-ontap')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "$/dev-projects/pulumi-netapp-ontap/sdk/python/pulumiverse_netapp-ontap/__init__.py", line 15
import pulumiverse_netapp-ontap.cluster as __cluster
^
SyntaxError: invalid syntax
My conclusion so far is that bridging this provider is not possible because a hypen character is used in the terraform provider name.
Btw.
To gain some more TF-bridge experience, I also tried to bridge configcat (https://github.com/configcat/terraform-provider-configcat).
Unfortunately that didn't work either.
Anyone already encountered the error below?
Steps to reproduce:
[1/26] terraform_provider_name (terraform-provider-name): configcat
[2/26] terraform_provider_org (terraform-providers): configcat
[3/26] terraform_provider_source (<http://github.com/configcat/terraform-provider-configcat|github.com/configcat/terraform-provider-configcat>):
[4/26] terraform_provider_version_or_commit (0.0.0): 5.4.0
[5/26] terraform_provider_module (<http://github.com/configcat/terraform-provider-configcat/v5|github.com/configcat/terraform-provider-configcat/v5>): <http://github.com/configcat/terraform-provider-configcat|github.com/configcat/terraform-provider-configcat>
[6/26] terraform_provider_package_name (configcat): internal/configcat
[7/26] Select terraform_sdk_version
1 - 1
2 - 2
3 - plugin-framework
Choose from [1/2/3] (1): 3
....
modified shim.go
package shim
import (
"<http://github.com/configcat/terraform-provider-configcat/internal/configcat|github.com/configcat/terraform-provider-configcat/internal/configcat>"
tfpf "<http://github.com/hashicorp/terraform-plugin-framework/provider|github.com/hashicorp/terraform-plugin-framework/provider>"
)
func NewProvider() tfpf.Provider {
return configcat.New("dev")()
}
Gives an error:
error: Resource configcat_webhook has a problem: "id" attribute is of type "Int", expected type "string". To map this resource consider overriding the SchemaInfo.Type field or specifying ResourceInfo.ComputeID
Additional example conversion stats are available by setting COVERAGE_OUTPUT_DIR.
Provider: configcat
Success rate: NaN% (0/0)
General metrics:
0 total resources containing 0 total inputs.
0 total functions.
But I don't know how to override SchemaInfo.Type or specify ResourceInfo.ComputeID
All help is welcome 🙂
Regards,
Davidminiature-twilight-47355
08/15/2024, 4:52 PMminiature-twilight-47355
08/15/2024, 5:07 PMid
parameter is treated specially by pulumi and must be a string (Resource Provider Implementer’s Guide — Pulumi documentation), you have two options:
1) Just make it a string in the pulumi schema (eg: [Breaking] Set workspace_id to a string instead of int for Pulumi · pulumi-databricks/435) and let the bridge convert it to an Int for the underlying terraform provider code.
2) Rename that field to something else and tell the bridge to use some other string as the ID (by setting ComputeID
on the resource)limited-rainbow-51650
08/20/2024, 6:39 AMambitious-crayon-4360
08/21/2024, 10:31 AMambitious-crayon-4360
09/03/2024, 8:23 PMYou can then import the SDK in your Python code with:
import pulumi_netapp-ontap as netapp-ontap
So that must be:
import pulumi_netapp_ontap as netapp_ontap
Regards,
David