Myra-Security-GmbH/terraform-provider-myrasec

Trouble to apply with myrasec_dns_record

Closed this issue · 4 comments

Hi,

When using resource type myrasec_dns_record, I tried to apply a simple new dns record, but appeared an error message.
I checked on Myra side and actually the apply worked and so it uploaded the dns record properly BUT not my state.

Here is the output of the error:


│ Error: Plugin did not respond

│ with myrasec_dns_record.<RESOURCE_NAME>[""],
│ on terraform.tf line 1, in resource "myrasec_dns_record" "<RESOURCE_NAME>":
│ 1: resource "myrasec_dns_record" "<RESOURCE_NAME>" {

│ 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-myrasec_v1.20.0 plugin:

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

goroutine 75 [running]:
github.com/Myra-Security-GmbH/terraform-provider-myrasec/myrasec.resourceMyrasecDNSRecordRead({0xc00017f100, 0xc00025e380}, 0xc00017f100, {0x17b3fe0, 0xc00048b0e0})
github.com/Myra-Security-GmbH/terraform-provider-myrasec/myrasec/resource_myrasec_dns_record.go:275 +0xb0a
github.com/Myra-Security-GmbH/terraform-provider-myrasec/myrasec.resourceMyrasecDNSRecordCreate({0x18c3328, 0xc00048aea0}, 0xc0000d9668, {0x17b3fe0, 0xc00048b0e0})
github.com/Myra-Security-GmbH/terraform-provider-myrasec/myrasec/resource_myrasec_dns_record.go:203 +0x34f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc00038da40, {0x18c32b8, 0xc000411000}, 0x2, {0x17b3fe0, 0xc00048b0e0})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:341 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00038da40, {0x18c32b8, 0xc000411000}, 0xc00039f110, 0xc00017ef80, {0x17b3fe0, 0xc00048b0e0})
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(0xc000312078, {0x18c32b8, 0xc000411000}, 0xc00057e460)
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(0xc0003d20a0, {0x18c3360, 0xc0002a4e40}, 0xc000296150)
github.com/hashicorp/terraform-plugin-go@v0.7.0/tfprotov5/tf5server/server.go:810 +0x5eb
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x17968e0, 0xc0003d20a0}, {0x18c3360, 0xc0002a4e40}, 0xc00048a360, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.7.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00032a700, {0x18cff78, 0xc0003f4820}, 0xc000802a20, 0xc0003d5200, 0x1d8ca80, 0x0)
google.golang.org/grpc@v1.44.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc00032a700, {0x18cff78, 0xc0003f4820}, 0xc000802a20, 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-myrasec_v1.20.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.`

Hello @lejardindeden,

From your output, it looks like the provider has some issues.
I tried to reproduce this issue but for me, this worked as expected.
Can you please provide more information about the resource you want to import and the steps you did?
In case this contains sensitive data, please send this information to our support team.

Example of a DNS record I created:

resource "myrasec_dns_record" "www_example_com" {
  domain_name = var.domain_name
  name = "www.example.com"
  ttl = 300
  record_type = "A"
  value = var.record_ip
}

We will have a further look on this issue. Please ensure that the DNS record you want to create does not yet exist (for example).
I will inform you as soon as I have some more information about this issue.

@lejardindeden
I was able to reproduce this issue and pushed a fix for this. Using v1.20.1 should contain a fix for this.

Please let me know if it works for you.

Hi @xellio,

It seems indeed that the issue is resolved!

Thank you.