Unrelated error with sort_order
Describe the bug Trying to import an existing index using a config driven approach. I get "Error: sort_order: '': source data must be an array or slice, got string".
To Reproduce Steps to reproduce the behavior:
- Following terraform should import the index and be managed within terraform going forward `terraform { backend "remote" { hostname = "tfe.robot.car" organization = "sampleorg" workspaces { prefix = "workspaceprefix" } }
required_providers { elasticstack = { source = "elastic/elasticstack" version = "~>0.11" } } }
provider "elasticstack" { elasticsearch { endpoints = ["http://localhost:9090"] username = "username" password = "password" } }
resource "elasticstack_elasticsearch_index" "sample" { name = "sample-index"
alias { name = "sample-xx" }
alias { name = "[email protected]" is_write_index = true } sort_field = ["timestamp"] sort_order = ["desc"] }
import { to = elasticstack_elasticsearch_index.sample id = "<cluster_id>/sample-index" }`
- Run
terraform initand thenterraform plan - See the error in the output.
Error: sort_order: '': source data must be an array or slice, got string
However, if i dont include sort order i get the following crash error:
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ImportResourceState call. The plugin logs may
│ contain more details.
╵
Stack trace from the terraform-provider-elasticstack_v0.11.0 plugin:
panic: interface conversion: interface {} is string, not *schema.Set
goroutine 191 [running]:
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).setSet(0xc000982270, {0xc00069ea80, 0x1, 0x1}, {0x12450e0, 0xc000034290}, 0xc0003d28c0)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_writer_map.go:346 +0x705
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).set(0xc000982270, {0xc00069ea80, 0x1, 0x1}, {0x12450e0, 0xc000034290})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_writer_map.go:110 +0x13c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).WriteField(0xc000982270, {0xc00069ea80, 0x1, 0x1}, {0x12450e0, 0xc000034290})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_writer_map.go:92 +0x3d8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc0006ce500, {0xc000551340, 0xa}, {0x12450e0, 0xc000034290})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource_data.go:230 +0x1cc
github.com/elastic/terraform-provider-elasticstack/internal/elasticsearch/index.ResourceIndex.func1({0x1683100, 0xc000a85080}, 0xc0006ce500, {0x1418280, 0xc00054eea0})
github.com/elastic/terraform-provider-elasticstack/internal/elasticsearch/index/index.go:625 +0x6b4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0xc000148d80, {0x1683100, 0xc000a85080}, 0xc0005b94a8, {0xc0001be040, 0x37})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/provider.go:394 +0x20c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0xc00013b218, {0x1683100?, 0xc000a84f90?}, 0xc0006c2140)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1142 +0xe5
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ImportResourceState({{0x1689f80?, 0xc00013b218?}}, {0x1683100?, 0xc000a84f90?}, 0xc0006c2120?)
github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:81 +0xc5
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ImportResourceState(0x1683138?, {0x1683100?, 0xc000a84c90?}, 0xc0006c2120)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ImportResourceState.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ImportResourceState(0xc0002d61e0, {0x1683100?, 0xc000a84390?}, 0xc0006b62d0)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:887 +0x1e2
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ImportResourceState_Handler({0x1438120?, 0xc0002d61e0}, {0x1683100, 0xc000a84390}, 0xc0006ce000, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:485 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004fe000, {0x1683100, 0xc000a84300}, {0x1688a00, 0xc0006029c0}, 0xc00098a240, 0xc000425c50, 0x2113f50, 0x0)
google.golang.org/[email protected]/server.go:1343 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc0004fe000, {0x1688a00, 0xc0006029c0}, 0xc00098a240)
google.golang.org/[email protected]/server.go:1737 +0xc4c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:986 +0x86
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 104
google.golang.org/[email protected]/server.go:997 +0x145
Error: The terraform-provider-elasticstack_v0.11.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 The resource should be imported without any errors
Versions (please complete the following information):
- OS: MacOS
- Terraform Version - v1.5.3 on darwin_amd64
- Provider version - v0.11.0