zitadel / terraform-provider-zitadel

Official Terraform provider for ZITADEL
https://zitadel.com
Apache License 2.0
21 stars 13 forks source link

Plugin did not respond #141

Open mr42 opened 7 months ago

mr42 commented 7 months ago

Preflight Checklist

Version

1.0.4

ZITADEL Version

v2.40.5

Describe the problem caused by this bug

I always get the error when I try to run terraform apply:

Error: Plugin did not respond │ │ The plugin encountered an error, and failed to respond to the │ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may │ contain more details.

My Terraform file looks the following:

terraform {
  cloud {
    organization = "Econgood"

    workspaces {
      name = "zitadel"
    }
  }
  required_providers {
    zitadel = {
      source  = "zitadel/zitadel"
      version = "1.0.4"
    }
  }
}

provider "zitadel" {
  domain           = "https://econgood-bhxxvq.zitadel.cloud"
  insecure         = "false"
  port             = "443"
  jwt_profile_file = ".zitadel_key.json"
}

resource "zitadel_org" "econgood" {
  name = "Econgood"
  is_default = true
}

The detailed stacktrace is:

Stack trace from the terraform-provider-zitadel_v1.0.4 plugin:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xba9a3e]

goroutine 87 [running]: github.com/zitadel/oidc/pkg/crypto.BytesToPrivateKey({0xc000698e00?, 0x7fb66a9dc7c8?, 0x7fb691f61108?}) github.com/zitadel/oidc@v1.13.4/pkg/crypto/key.go:11 +0x1e github.com/zitadel/oidc/pkg/client.NewSignerFromPrivateKeyByte({0xc000698e00?, 0x700?, 0xc0006b4820?}, {0xc00004b4a0, 0x12}) github.com/zitadel/oidc@v1.13.4/pkg/client/client.go:152 +0x32 github.com/zitadel/oidc/pkg/client/profile.NewJWTProfileTokenSource({0xc00020c930, 0x2d}, {0xc00004b4b8, 0x12}, {0xc00004b4a0?, 0x19b?}, {0xc000698e00?, 0xc0006b4950?, 0x415d10?}, {0xc00029a3e0, ...}, ...) github.com/zitadel/oidc@v1.13.4/pkg/client/profile/jwt_profile.go:43 +0x5c github.com/zitadel/oidc/pkg/client/profile.NewJWTProfileTokenSourceFromKeyFile({0xc00020c930, 0x2d}, {0xc00004ab10?, 0x1127e04?}, {0xc00029a3e0, 0x2, 0x2}, {0x0, 0x0, 0x0}) github.com/zitadel/oidc@v1.13.4/pkg/client/profile/jwt_profile.go:31 +0x12a github.com/zitadel/zitadel-go/v2/pkg/client/middleware.JWTProfileFromPath.func1({0xc00020c930?, 0xc14bb7e85204d334?}, {0xc00029a3e0?, 0x40d90a?, 0xc000011470?}) github.com/zitadel/zitadel-go/v2@v2.0.21/pkg/client/middleware/auth.go:29 +0x48 github.com/zitadel/zitadel-go/v2/pkg/client/middleware.NewAuthenticator({0xc00020c930?, 0x10f0fa0?}, 0xc000500400?, {0xc00029a3e0?, 0x7fb691f61108?, 0x90?}) github.com/zitadel/zitadel-go/v2@v2.0.21/pkg/client/middleware/auth.go:49 +0x34 github.com/zitadel/zitadel-go/v2/pkg/client/zitadel.(Connection).setInterceptors(0xc00001f440, {0xc00020c930?, 0x415d10?}, {0x0, 0x0}, {0xc00029a3e0?, 0x1c4d318?, 0x0?}, 0x0?) github.com/zitadel/zitadel-go/v2@v2.0.21/pkg/client/zitadel/client.go:69 +0x57 github.com/zitadel/zitadel-go/v2/pkg/client/zitadel.NewConnection({0xc00020c930, 0x2d}, {0xc00020c960, 0x29}, {0xc00029a3e0, 0x2, 0x2}, {0xc000180be8, 0x1, 0x1}) github.com/zitadel/zitadel-go/v2@v2.0.21/pkg/client/zitadel/client.go:41 +0x1cb github.com/zitadel/zitadel-go/v2/pkg/client/management.NewClient({0xc00020c930?, 0x1?}, {0xc00020c960?, 0x0?}, {0xc00029a3e0?, 0x0?, 0x0?}, {0xc000180be8, 0x1, 0x1}) github.com/zitadel/zitadel-go/v2@v2.0.21/pkg/client/management/client.go:14 +0x58 github.com/zitadel/terraform-provider-zitadel/zitadel/helper.GetManagementClient(0xc0005a6b40) github.com/zitadel/terraform-provider-zitadel/zitadel/helper/client.go:115 +0x1ca github.com/zitadel/terraform-provider-zitadel/zitadel/org.create({0x1391c08, 0xc000645b60}, 0x0?, {0xec88c0?, 0xc0005a6b40}) github.com/zitadel/terraform-provider-zitadel/zitadel/org/funcs.go:43 +0xa5 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).create(0xc000193ea0, {0x1391c40, 0xc0006451a0}, 0xd?, {0xec88c0, 0xc0005a6b40}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:707 +0x12e github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).Apply(0xc000193ea0, {0x1391c40, 0xc0006451a0}, 0xc00058c9c0, 0xc000361480, {0xec88c0, 0xc0005a6b40}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:837 +0xa85 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ApplyResourceChange(0xc0001942b8, {0x1391c40?, 0xc000644fc0?}, 0xc0007095e0) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:1021 +0xe8d github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x13974c8?, 0xc0001942b8?}}, {0x1391c40, 0xc000644fc0}, 0x0?) github.com/hashicorp/terraform-plugin-mux@v0.7.0/tf5to6server/tf5to6server.go:34 +0x5a github.com/hashicorp/terraform-plugin-mux/tf6muxserver.muxServer.ApplyResourceChange({0xc0000bc7b0, 0xc0000bc810, {0xc00029a720, 0x2, 0x2}, 0xc0000bc7e0, 0xc000188530, 0xc00024f330, 0xc0000bc840}, {0x1391c40, ...}, ...) github.com/hashicorp/terraform-plugin-mux@v0.7.0/tf6muxserver/mux_server_ApplyResourceChange.go:27 +0x142 github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(server).ApplyResourceChange(0xc000283540, {0x1391c40?, 0xc0006442a0?}, 0xc000357c70) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov6/tf6server/server.go:816 +0x574 github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x10c2bc0?, 0xc000283540}, {0x1391c40, 0xc0006442a0}, 0xc000357b90, 0x0) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:385 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0xc0000cc780, {0x13969f8, 0xc0004f4680}, 0xc00059eea0, 0xc0006464b0, 0x1bffd40, 0x0) google.golang.org/grpc@v1.58.1/server.go:1376 +0xdd2 google.golang.org/grpc.(Server).handleStream(0xc0000cc780, {0x13969f8, 0xc0004f4680}, 0xc00059eea0, 0x0) google.golang.org/grpc@v1.58.1/server.go:1753 +0xa36 google.golang.org/grpc.(Server).serveStreams.func1.1() google.golang.org/grpc@v1.58.1/server.go:998 +0x98 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.58.1/server.go:996 +0x18c

Error: The terraform-provider-zitadel_v1.0.4 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

To reproduce

  1. Create instance
  2. Create service user with all rights enabled for the instance
  3. Create JSON key file for this user
  4. Run terraform apply

Screenshots

No response

Expected behavior

No error or at least a meaningful error message.

Relevant Configuration

No response

Additional Context

No response

mr42 commented 7 months ago

I fix the problem like the following. I created a new key file. This time I left the key file name as it is and I removed the schema part from the domain so my tf file is now:

terraform {
  cloud {
    organization = "Econgood"

    workspaces {
      name = "zitadel"
    }
  }
  required_providers {
    zitadel = {
      source  = "zitadel/zitadel"
      version = "1.0.4"
    }
  }
}

provider "zitadel" {
  domain           = "econgood-bhxxvq.zitadel.cloud"
  insecure         = "false"
  port             = "443"
  jwt_profile_file = "240153128350007051.json"
}

resource "zitadel_org" "econgood" {
  name = "Econgood"
  is_default = true
}

I mean I fixed it this way, but I think a good error message would help in the future to know what has to be changed.