(*GRPCProvider).ReadResource error while adding DNS resource

Hi people, hope you are well.

I need some help with this error (*GRPCProvider).ReadResource meanwhile i’m trying to add a data “google_dns_record_set” in a main.tf of resource “google_redis_instance”. Managed zone, name of dns zone and type “CNAME” also with project id is set up.

│ Error: Request cancelled
│
│   with data.google_dns_record_set.stable,
│   on main.tf line 44, in data "google_dns_record_set" "stable":
│   44: data "google_dns_record_set" "stable" {
│
│ The plugin.(*GRPCProvider).ReadDataSource request was cancelled.
╵

Stack trace from the terraform-provider-google_v5.12.0_x5 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 202 [running]:
github.com/hashicorp/terraform-provider-google/google/services/dns.(*GoogleDnsRecordSetDataSource).Read(0xc001474720, {0x42afb78, 0xc0015f0870}, {{{{0x42b8e68, 0xc0015fe660}, {0x35eeb00, 0xc0015f1ef0}}, {0x42ba6f8, 0xc000f89580}}, {{{0x42b8e68, ...}, ...}, ...}}, ...)
	github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_record_set.go:147 +0xca5
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadDataSource(0xc000037a20, {0x42afb78, 0xc0015f0870}, 0xc0015f0bd0, 0xc001b693b8)
	github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/fwserver/server_readdatasource.go:75 +0x4ad
github.com/hashicorp/terraform-plugin-framework/internal/proto5server.(*Server).ReadDataSource(0xc000037a20, {0x42afb78?, 0xc0015f01e0?}, 0xc001474700)
	github.com/hashicorp/terraform-plugin-framework@v1.1.1/internal/proto5server/server_readdatasource.go:52 +0x42f
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ReadDataSource({0xc000c5d830, 0xc000c5d890, {0xc001907640, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
	github.com/hashicorp/terraform-plugin-mux@v0.8.0/tf5muxserver/mux_server_ReadDataSource.go:27 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0xc0011aa140, {0x42afb78?, 0xc0015ed9b0?}, 0xc001161040)
	github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:658 +0x403
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x3b059c0?, 0xc0011aa140}, {0x42afb78, 0xc0015ed9b0}, 0xc0013b5d80, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:421 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc001104000, {0x42afb78, 0xc0015ed710}, {0x42b9318, 0xc00190f1e0}, 0xc0016fac60, 0xc000f3d800, 0x5bc43b0, 0x0)
	google.golang.org/grpc@v1.60.0/server.go:1372 +0xe49
google.golang.org/grpc.(*Server).handleStream(0xc001104000, {0x42b9318, 0xc00190f1e0}, 0xc0016fac60)
	google.golang.org/grpc@v1.60.0/server.go:1783 +0x1031
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.60.0/server.go:1016 +0x68
created by google.golang.org/grpc.(*Server).serveStreams.func2
	google.golang.org/grpc@v1.60.0/server.go:1027 +0x12e

Error: The terraform-provider-google_v5.12.0_x5 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.

Kindly help with this, thanks in advance.

It seems you’re encountering a runtime panic error while trying to read a DNS record set using Terraform with the Google provider. The error message “index out of range [0] with length 0” typically indicates that the code is trying to access an element of a slice or array that doesn’t exist, which in this context, suggests an issue with the data being retrieved or how it’s being processed by Terraform.

Any suggestions how to check it further?

The error indicates this is a crash in the provider, so there may not be much you can do from within your configuration except to try and work around the bug. Searching the provider issues brings up Crash Report for google_dns_record_set · Issue #15797 · hashicorp/terraform-provider-google · GitHub, which may have more information.

This is solved, adding this to the code:

 rrdatas = [google_redis_instance.redis-instance.host]