disaster37 / terraform-provider-kibana

Custom provider to handle Kibana API
MIT License
11 stars 21 forks source link

Crash when setting metadata #30

Closed artificial-aidan closed 2 years ago

artificial-aidan commented 2 years ago
resource kibana_role "admin" {
  name                 = "kibana-admin"
  elasticsearch {
    indices {
        names       = ["*"]
        privileges  = ["read"]
    }
    cluster = ["all"]
  }
  kibana {
      base = ["all"]
      spaces = ["*"]
  }

  metadata = jsonencode({
    "version" = 1
  })

Log:

│   with kibana_role.viewer,
│   on main.tf line 149, in resource "kibana_role" "viewer":
│  149: resource kibana_role "viewer" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain
│ more details.
╵

Stack trace from the terraform-provider-kibana_v8.0.1 plugin:

panic: interface conversion: interface {} is json.RawMessage, not map[string]interface {}

goroutine 54 [running]:
github.com/disaster37/terraform-provider-kibana/v8/kb.createRole(0x17499c0, {0x16f28e0, 0xc000530690})
    github.com/disaster37/terraform-provider-kibana/v8/kb/resource_kibana_role.go:269 +0x291
github.com/disaster37/terraform-provider-kibana/v8/kb.resourceKibanaRoleCreate(0x0, {0x16f28e0, 0xc000530690})
    github.com/disaster37/terraform-provider-kibana/v8/kb/resource_kibana_role.go:146 +0x79
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x174b400, {0x1939e18, 0xc00010c540}, 0x2, {0x16f28e0, 0xc000530690})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:329 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0001b2b60, {0x1939e18, 0xc00010c540}, 0xc00039da00, 0xc000756200, {0x16f28e0, 0xc000530690})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:467 +0x871
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0000bd308, {0x1939e18, 0xc00010c540}, 0xc00011e320)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000264aa0, {0x1939ec0, 0xc00073a030}, 0xc0001e0150)
    github.com/hashicorp/terraform-plugin-go@v0.7.1/tfprotov5/tf5server/server.go:812 +0x5eb
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x17f4c60, 0xc000264aa0}, {0x1939ec0, 0xc00073a030}, 0xc0001089c0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.7.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002d0a80, {0x1947898, 0xc00026ba00}, 0xc00036d0e0, 0xc0003b4300, 0x1e50640, 0x0)
    google.golang.org/grpc@v1.44.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0002d0a80, {0x1947898, 0xc00026ba00}, 0xc00036d0e0, 0x0)
    google.golang.org/grpc@v1.44.0/server.go:1616 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
    google.golang.org/grpc@v1.44.0/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.44.0/server.go:919 +0x294

Error: The terraform-provider-kibana_v8.0.1 plugin crashed!
artificial-aidan commented 2 years ago

I found the issue and will have a PR up shortly.

disaster37 commented 2 years ago

It's resolv by your PR. Thx