Closed Kikivsantos closed 1 year ago
Thanks for opening this issue. The ticket INTMDB-955 was created for internal tracking.
Hello @Kikivsantos,
Thanks for opening the issue. I was able to reproduce the failure: the reason why the provider is panicking is that you are providing metric_threshold_config {}
as an empty object. The fix is to remove metric_threshold_config
if it has no attributes inside. With that said, the provider should not panic in this scenario and we are fixing this issue in https://github.com/mongodb/terraform-provider-mongodbatlas/pull/1342
Hello, The fix was released in v1.11.0.. Feel free to reopen the issue if you still have the same problem with the latest version.
Thanks
HI, @andreaangiolillo I'm still getting error
My version:
$ terraform version
Terraform v1.5.3
on linux_amd64
+ provider registry.terraform.io/mongodb/mongodbatlas v1.11.0
My terragrunt file:
locals {
component_name = "modules/alert"
#environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl")).locals
component_version = "feature-addalert"
}
include "root" {
path = "${get_repo_root()}/terragrunt.hcl"
}
dependency "project" {
config_path = "../.."
}
inputs = {
project_id = dependency.project.outputs.project_id
#environment = local.environment_vars.environment
event_type = "NO_PRIMARY"
enabled = false
notification = {
type_name = "GROUP"
interval_min = 60
delay_min = 0
sms_enabled = false
email_enabled = true
roles = ["GROUP_OWNER"]
}
}
My main.tf:
resource "mongodbatlas_alert_configuration" "default" {
project_id = var.project_id #var.project_id[var.environment]
event_type = var.event_type #"OUTSIDE_METRIC_THRESHOLD"
enabled = var.enabled
notification {
type_name = var.type_name #"GROUP"
interval_min = var.interval_min # 5
delay_min = var.delay_min #0
sms_enabled = var.sms_enabled #false
email_enabled = var.email_enabled #true
roles = var.roles #["GROUP_OWNER", "GROUP_CLUSTER_MANAGER"]
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) #"ASSERT_REGULAR"
operator = try(var.metric_threshold_config.operator, null) #"LESS_THAN"
threshold = try(var.metric_threshold_config.threshold, null)#99.0
units = try(var.metric_threshold_config.units, null)#"RAW"
mode = try(var.metric_threshold_config.mode, null)#"AVERAGE"
}
threshold_config {
operator = try(var.threshold_config.operator, null) #"LESS_THAN"
threshold = try(var.threshold_config.threshold, null)#99.0
units = try(var.threshold_config.units, null)#"RAW"
}
}
I try commenting the threshold_config part and the matcher (code below), but the error still happens.
resource "mongodbatlas_alert_configuration" "default" {
project_id = var.project_id #var.project_id[var.environment]
event_type = var.event_type #"OUTSIDE_METRIC_THRESHOLD"
enabled = var.enabled
notification {
type_name = var.type_name #"GROUP"
interval_min = var.interval_min # 5
delay_min = var.delay_min #0
sms_enabled = var.sms_enabled #false
email_enabled = var.email_enabled #true
roles = var.roles #["GROUP_OWNER", "GROUP_CLUSTER_MANAGER"]
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) #"ASSERT_REGULAR"
operator = try(var.metric_threshold_config.operator, null) #"LESS_THAN"
threshold = try(var.metric_threshold_config.threshold, null)#99.0
units = try(var.metric_threshold_config.units, null)#"RAW"
mode = try(var.metric_threshold_config.mode, null)#"AVERAGE"
}
# threshold_config {
# operator = try(var.threshold_config.operator, null) #"LESS_THAN"
# threshold = try(var.threshold_config.threshold, null)#99.0
# units = try(var.threshold_config.units, null)#"RAW"
# }
}
This is the error I'm getting:
│ 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 27 [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, 0xc000977a40}, 0x0?, {0x121f160?, 0xc00013c4b0?})
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(0xc0008048c0, {0x1758980, 0xc0007f3b90}, 0xd?, {0x121f160, 0xc00013c4b0})
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(0xc0008048c0, {0x1758980, 0xc0007f3b90}, 0xc000956820, 0xc00011eb00, {0x121f160, 0xc00013c4b0})
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(0xc000127b18, {0x1758980?, 0xc0007f3a70?}, 0xc0006b4460)
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(0xc0000b72c0, {0x1758980?, 0xc0007f21b0?}, 0xc000712150)
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?, 0xc0000b72c0}, {0x1758980, 0xc0007f21b0}, 0xc0007120e0, 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(0xc00020e000, {0x175d5a0, 0xc00053c1a0}, 0xc000b0a000, 0xc0008174d0, 0x1ffc080, 0x0)
google.golang.org/grpc@v1.56.1/server.go:1337 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc00020e000, {0x175d5a0, 0xc00053c1a0}, 0xc000b0a000, 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.
Thanks
PS: I have created this new Issue for the problem: https://github.com/mongodb/terraform-provider-mongodbatlas/issues/1396
Terraform CLI and Terraform MongoDB Atlas Provider Version
Terraform Configuration File
Steps to Reproduce
terraform apply
Expected Behavior
Should have created an alert on mongodb atlas (on the develop project)
Actual Behavior
Debug Output
Crash Output
Additional Context
References