Skip to content

[Bug] panic using elasticstack_elasticsearch_security_user data source #73

@artm

Description

@artm

Describe the bug

When attempting to use the provider it crashes with a runtime error.

To Reproduce

  1. TF configuration used
terraform {
  required_providers {
    elasticstack = {
      source  = "elastic/elasticstack"
      version = "0.3.0"
    }
  }
}

provider "elasticstack" {
  elasticsearch {
    username  = "elastic"
    password  = "*********"
    endpoints = ["https://*********:443/"]
  }
}

data "elasticstack_elasticsearch_security_user" "user" {
  username = "elastic"
}
  1. TF operations to execute to get the error
terraform init
terraform apply
  1. See the error in the output
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- terraform.io/builtin/terraform is built in to Terraform
- Reusing previous version of elastic/elasticstack from the dependency lock file
- Using previously-installed elastic/elasticstack v0.3.0

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Success! The configuration is valid.

╷
│ Error: Request cancelled
│ 
│   with module.config.data.elasticstack_elasticsearch_security_user.user,
│   on ../../../elastic/modules/tf-linux-logging-conf/main.tf line 25, in data "elasticstack_elasticsearch_security_user" "user":
│   25: data "elasticstack_elasticsearch_security_user" "user" {
│ 
│ The plugin.(*GRPCProvider).ReadDataSource request was cancelled.
╵

Stack trace from the terraform-provider-elasticstack_v0.3.0 plugin:

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

goroutine 70 [running]:
github.com/elastic/terraform-provider-elasticstack/internal/elasticsearch/security.dataSourceSecurityUserRead({0x1220ff8, 0xc00030b700}, 0x7f76ee0241d8, {0x10aec00, 0xc00000dbc0})
        github.com/elastic/terraform-provider-elasticstack/internal/elasticsearch/security/user_data_source.go:83 +0x17f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0003d2380, {0x1220ff8, 0xc00030b700}, 0xc000542b10, {0x10aec00, 0xc00000dbc0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:358 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0003d2380, {0x1220ff8, 0xc00030b700}, 0xc000446980, {0x10aec00, 0xc00000dbc0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:569 +0xf7
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc0001240a8, {0x1220ff8, 0xc00030b700}, 0xc00011f280)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/grpc_provider.go:1133 +0x3a8
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0xc00004eb80, {0x12210a0, 0xc000539e60}, 0xc0002ae000)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:478 +0x37b
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x1075320, 0xc00004eb80}, {0x12210a0, 0xc000539e60}, 0xc000300d80, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:416 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002a0700, {0x122e278, 0xc000370000}, 0xc0000c6d80, 0xc0002b7c80, 0x1aca830, 0x0)
        google.golang.org/grpc@v1.42.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0002a0700, {0x122e278, 0xc000370000}, 0xc0000c6d80, 0x0)
        google.golang.org/grpc@v1.42.0/server.go:1616 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.42.0/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.42.0/server.go:919 +0x294

Error: The terraform-provider-elasticstack_v0.3.0 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.

Expected behavior

no error

I'll submit the trace log in a comment later

Versions (please complete the following information):

  • OS: Linux
  • Terraform Version 1.0.8
  • Provider version 0.3.0
  • Elasticsearch Version 7.17.0

Metadata

Metadata

Assignees

Labels

ElasticsearchElasticsearch related APIsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions