Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The terraform-provider-mongodbatlas_v1.11.0 plugin crashed #1396

Closed
Kikivsantos opened this issue Aug 17, 2023 · 4 comments
Closed

Error: The terraform-provider-mongodbatlas_v1.11.0 plugin crashed #1396

Kikivsantos opened this issue Aug 17, 2023 · 4 comments
Labels

Comments

@Kikivsantos
Copy link

HI, there.

I'm trying to create an alert on MongoDB Atlas with terraform, but I´m getting the error below:


mongodbatlas_alert_configuration.default: Creating...
╷
│ Error: Plugin did not respond
│ 
│   with mongodbatlas_alert_configuration.default,
│   on main.tf line 2, in resource "mongodbatlas_alert_configuration" "default":
│    2: resource "mongodbatlas_alert_configuration" "default" {
│
│ 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-mongodbatlas_v1.11.0 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 10 [running]:
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas.expandAlertConfigurationThresholdConfig(0x4143e5?)
        github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_alert_configuration.go:613 +0x314
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas.resourceMongoDBAtlasAlertConfigurationCreate({0x1758948, 0xc00033e1e0}, 0x0?, {0x121f160?, 0xc000927830?})
        github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_alert_configuration.go:307 +0x185
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0006fc8c0, {0x1758980, 0xc00058ef30}, 0xd?, {0x121f160, 0xc000927830})    
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:733 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0006fc8c0, {0x1758980, 0xc00058ef30}, 0xc000a80820, 0xc00077eb00, {0x121f160, 0xc000927830})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:864 +0xa7e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000107b30, {0x1758980?, 0xc00058ee10?}, 0xc000632550)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:1024 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000252640, {0x1758980?, 0xc00058e3f0?}, 0xc0006282a0)        
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x137a400?, 0xc000252640}, {0x1758980, 0xc00058e3f0}, 0xc000628150, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000361e0, {0x175d5a0, 0xc0004ba680}, 0xc0000ee000, 0xc00070f4d0, 0x1ffc080, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1337 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc0000361e0, {0x175d5a0, 0xc0004ba680}, 0xc0000ee000, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1714 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.56.1/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.56.1/server.go:957 +0x18c

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

ERRO[0021] Terraform invocation failed in /mnt/c/Users/CristianaValentedosS/git/mongodb-atlas-org/terraform/resources/projects/develop/alert/cluster_mongos_is_missing/.terragrunt-cache/-vE2IoKwpR8Qn6YW6jqFC5sPFIU/pzZ6kKKOog-nM-3feLfydekfdws/modules/alert  prefix=[/mnt/c/Users/CristianaValentedosS/git/mongodb-atlas-org/terraform/resources/projects/develop/alert/cluster_mongos_is_missing]
ERRO[0021] 1 error occurred:
        * [/mnt/c/Users/CristianaValentedosS/git/mongodb-atlas-org/terraform/resources/projects/develop/alert/cluster_mongos_is_missing/.terragrunt-cache/-vE2IoKwpR8Qn6YW6jqFC5sPFIU/pzZ6kKKOog-nM-3feLfydekfdws/modules/alert] exit status 1

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.5.3

Terraform Configuration File

terraform configuration file:

resource "mongodbatlas_alert_configuration" "default" {
  project_id = var.project_id 
  event_type = var.event_type 
  enabled    = var.enabled

  notification {
    type_name     = var.type_name
    interval_min  = var.interval_min
    delay_min     = var.delay_min 
    sms_enabled   = var.sms_enabled 
    email_enabled = var.email_enabled
    roles         = var.roles 
    api_token        = try(var.api_token, null)
  }
  
  matcher {
    field_name = try(var.matcher.field_name, null)
    operator   = try(var.matcher.operator, null)
    value = try(var.matcher.value, null)
  }


  metric_threshold_config {
    metric_name = try(var.metric_threshold_config.metric_name, null)
    operator    = try(var.metric_threshold_config.operator, null) 
    threshold   = try(var.metric_threshold_config.threshold, null)
    units       = try(var.metric_threshold_config.units, null)
    mode        = try(var.metric_threshold_config.mode, null)
  }

  threshold_config {
    operator    = try(var.threshold_config.operator, null) 
    threshold   = try(var.threshold_config.threshold, null)
    units       = try(var.threshold_config.units, null)
  }
}

terragrunt configuration file:

locals {
  component_name = "modules/alert"
  component_version = "feature-addalert"
}

include "root" {
  path = "${get_repo_root()}/terragrunt.hcl"
}

dependency "project" {
  config_path = "../.."
}

inputs = {
  project_id   = dependency.project.outputs.project_id
  event_type = "CLUSTER_MONGOS_IS_MISSING" 
  enabled   = false

  notification = {
    type_name     = "GROUP"
    interval_min  = 60
    delay_min     = 0
    sms_enabled   = false
    email_enabled = true
    roles         = ["GROUP_OWNER"]
  }
  
} 

Steps to Reproduce

terragrun init
terragrun plan
terragrun apply

Expected Behavior

It should create an alert on Mongo Atlas

Actual Behavior

It returns error

Debug Output

Crash Output

Error: The terraform-provider-mongodbatlas_v1.11.0 plugin crashed!

Additional Context

References

There is this issue closed (but it is not from Atlas): hashicorp/terraform-provider-aws#22660

@github-actions
Copy link
Contributor

Thanks for opening this issue. The ticket INTMDB-1017 was created for internal tracking.

@andreaangiolillo
Copy link
Collaborator

Hello @Kikivsantos
Thanks for opening the issue. I was able to reproduce the issue and the fix will be available in 1.11.1. In the meantime, the workaround is to remove matcher, metric_threshold_config and threshold_config from your configuration since all theirs fields are null.

resource "mongodbatlas_project" "atlas-project" {
  name   = "TESTProj"
  org_id = "60ddf55c27a5a20955a707d7"
}

resource "mongodbatlas_alert_configuration" "default" {
  project_id = mongodbatlas_project.atlas-project.id
  event_type = "CLUSTER_MONGOS_IS_MISSING"
  enabled    = false

  notification {
    type_name     = "GROUP"
    interval_min  = 60
    delay_min     = 0
    sms_enabled   = false
    email_enabled = true
    roles         = ["GROUP_OWNER"]
    api_token     = ""
  }
}

Thanks

@andreaangiolillo
Copy link
Collaborator

Hello @Kikivsantos,
We released v1.11.1. Feel free to reopen the issue if you are still facing the same problem with v1.11.1.

Thanks

@Kikivsantos
Copy link
Author

Thank you, @andreaangiolillo

Now it worked to create the alerts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants