crossplane / terrajet

Generate Crossplane Providers from any Terraform Provider
https://crossplane.io
Apache License 2.0
289 stars 38 forks source link

Need tip with converting ldap provider #302

Closed IvanTurgenev1 closed 2 years ago

IvanTurgenev1 commented 2 years ago

Im trying to convert ldap provider(https://registry.terraform.io/providers/Ouest-France/ldap/latest/docs) there: https://github.com/wNvSp1r1T/terraform-jet-ldap/commit/8dfc0a9c1c41559ce91e0bacf25d4340c9b7b85c

And i'm always get error: "summary\":\"LDAP Result Code 34 \\"Invalid DN Syntax\\" 1.664437610235876e+09 DEBUG provider-jet-ldap Cannot observe external resource {"controller": "managed/ldapgroup.ldap.jet.crossplane.io/v1alpha1, kind=group", "request": "/hello-crossplane", "uid": "574384b6-1ec8-4bd9-9f1c-4b08821b7adb", "version": "208755", "external-name": "hello-crossplane", "error": "cannot run refresh: readObjectStart: expect { or n, but found 2, error found in #1 byte of ...

my examples/providerconfig/providerconfig.yaml is default one my examples/providerconfig/secret.yaml is

    {
      "host": "ldap.ru",
      "port": "389",
      "bind_user": "bind_user",
      "bind_password": "test-ldap"
    }

my examples/ldapgroup/ldapgroup.yaml is:

kind: Group
metadata:
  name: hello-crossplane
spec:
  forProvider:
    description: "Managed with Crossplane ldap Provider (generated with Terrajet)"
    ou: "OU=test,OU=sre,OU=Resources,OU=Main,DC=X,DC=eu
  providerConfigRef:
    name: default

I will be grateful for your help

Kerwood commented 2 years ago

It doesn't seem like you have created anything in your repo. Have you read this guide? https://github.com/crossplane/terrajet/blob/main/docs/generating-a-provider.md

IvanTurgenev1 commented 2 years ago

It doesn't seem like you have created anything in your repo. Have you read this guide? https://github.com/crossplane/terrajet/blob/main/docs/generating-a-provider.md

i'm sorry, but i'm forget to use git add :D now repo is up to date. https://github.com/wNvSp1r1T/terraform-jet-ldap/commit/40462d2347371938936cd0e7841f982d61047d46

Kerwood commented 2 years ago

Have you tried creating the resource with Terraform using the exact same values as in your Crossplane provider ?

IvanTurgenev1 commented 2 years ago

Have you tried creating the resource with Terraform using the exact same values as in your Crossplane provider ?

yep it's work fine with terraform or with terraform-provider (crossplane)

Kerwood commented 2 years ago

Have you tried setting r.ExternalName = tjconfig.IdentifierFromProvider in the Configure function ? Like so: https://github.com/ok-amba/provider-jet-opsgenie/blob/main/config/escalation/config.go#L26

IvanTurgenev1 commented 2 years ago

Have you tried setting r.ExternalName = tjconfig.IdentifierFromProvider in the Configure function ? Like so: https://github.com/ok-amba/provider-jet-opsgenie/blob/main/config/escalation/config.go#L26

Thanks for your reply. But it's didn't work :( DEBUG provider-jet-ldap Cannot observe external resource {"controller": "managed/ldapgroup.ldap.jet.crossplane.io/v1alpha1, kind=group", "request": "/hello-crossplane", "uid": "574384b6-1ec8-4bd9-9f1c-4b08821b7adb", "version": "210023", "external-name": "hello-crossplane", "error": "cannot run refresh: readObjectStart: expect { or n, but found 2, error found in #1 byte of ...|2022-10-03T|..., bigger context ...|2022-10-03T09:54:47.536+0300 [INFO] Terraform vers|...: refresh failed", "errorVerbose": "refresh failed\nreadObjectStart: expect { or n, but found 2 i get the same error error: LDAP Result Code 34 \"Invalid DN Syntax\": 0000208F: NameErr: DSID-03100229, problem 2006 (BAD_NAME), data 8350, best match of:\n\t'hello-crossplane'\n\u0000\n{\"@level\":\"error\",\"@message\":\"Error: LDAP Result Code 34 \\"Invalid DN Syntax\\

it's looks like DN name formed incorrectly, but i didn't get why, it's works with terraform as is

Kerwood commented 2 years ago

Have to tried using the newest Terraform version ? https://github.com/wNvSp1r1T/terraform-jet-ldap/blob/40462d2347371938936cd0e7841f982d61047d46/Makefile#L9

Also, for some reason, you are exporting TERRAFORM_VERSION twice in your Makefile

IvanTurgenev1 commented 2 years ago

Have to tried using the newest Terraform version ? https://github.com/wNvSp1r1T/terraform-jet-ldap/blob/40462d2347371938936cd0e7841f982d61047d46/Makefile#L9

Also, for some reason, you are exporting TERRAFORM_VERSION twice in your Makefile

looks like it's works right now thanks for your help!

IvanTurgenev1 commented 2 years ago

Also, is it possibly to disable option prevent_destroy? Cause this provider can-not update created element correctly

Kerwood commented 2 years ago

Do you mean deletionPolicy ? https://crossplane.io/docs/v1.9/concepts/managed-resources.html

IvanTurgenev1 commented 2 years ago

Do you mean deletionPolicy ? https://crossplane.io/docs/v1.9/concepts/managed-resources.html yup, looks like it. requests to create an object are made too often because of it duplicate objects appear. Is it possible to set the period between repeated requests?

Kerwood commented 2 years ago

No clue