terraform-provider-mongodbatlas
terraform-provider-mongodbatlas copied to clipboard
mongodbatlas_alert_configuration: serverless alerts not yet supported
I am using the terraform provider to manage a few projects in atlas. I was able to use this exact terraform on another project earlier today, but on this one it is failing with a 500 error.
I checked the mongodb cloud status page and it is all green.
Terraform CLI and Terraform MongoDB Atlas Provider Version
Terraform v0.14.11
+ provider registry.terraform.io/hashicorp/aws v3.39.0
+ provider registry.terraform.io/mongodb/mongodbatlas v1.3.1
Terraform Configuration File
provider "mongodbatlas" {}
Steps to Reproduce
- Create alert with slack notification:
resource "mongodbatlas_alert_configuration" "outside_serverless_metric_threshold" {
enabled = true
event_type = "OUTSIDE_SERVERLESS_METRIC_THRESHOLD"
project_id = mongodbatlas_project.<project>.id
metric_threshold_config {
metric_name = "SERVERLESS_CONNECTIONS_PERCENT"
mode = "AVERAGE"
operator = "GREATER_THAN"
threshold = 80
units = "RAW"
}
notification {
api_token = data.<removed>.value
channel_name = "<channel_name>"
delay_min = 0
email_enabled = false
interval_min = 60
roles = []
sms_enabled = false
type_name = "SLACK"
}
}
- terraform apply
Expected Behavior
Create the alert with a slack notification.
Actual Behavior
Error: error creating Alert Configuration information: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/
Debug Output
Request
---[ REQUEST ]---------------------------------------
POST /api/atlas/v1.0/groups/<removed>/alertConfigs HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.3.1 go-mongodbatlas/0.15.0 (linux;amd64)
Content-Length: 446
Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip
{
"eventTypeName": "OUTSIDE_SERVERLESS_METRIC_THRESHOLD",
"enabled": true,
"metricThreshold": {
"metricName": "SERVERLESS_CONNECTIONS_PERCENT",
"operator": "GREATER_THAN",
"threshold": 80,
"units": "RAW",
"mode": "AVERAGE"
},
"notifications": [
{
"apiToken": "<removed>",
"channelName": "<removed>",
"delayMin": 0,
"emailEnabled": false,
"intervalMin": 60,
"smsEnabled": false,
"typeName": "SLACK"
}
]
}
Response
---[ RESPONSE ]--------------------------------------
HTTP/2.0 500 Internal Server Error
Content-Length: 122
Content-Type: application/json
Date: Mon, 25 Apr 2022 15:57:41 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: envoy
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 112
X-Frame-Options: DENY
X-Mongodb-Service-Version: gitHash=57d8e6aa941ba69861cedc58e76ae6da63ec0a8b; versionString=v20220420
X-Permitted-Cross-Domain-Policies: none
{
"detail": "Unexpected error.",
"error": 500,
"errorCode": "UNEXPECTED_ERROR",
"parameters": [],
"reason": "Internal Server Error"
}
Crash Output
mongodbatlas_alert_configuration.outside_serverless_metric_threshold: Creating...
Error: error creating Alert Configuration information: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/<removed>/alertConfigs: 500 (request "UNEXPECTED_ERROR") Unexpected error.
2022-04-25T12:16:34.251-0400 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
on alerts.tf line 175, in resource "mongodbatlas_alert_configuration" "outside_serverless_metric_threshold":
175: resource "mongodbatlas_alert_configuration" "outside_serverless_metric_threshold" {
Additional Context
Terraform plan looks like I would expect. This alert configuration is working on another project, and I can create it via the web ui for the failing project.
The slack integration is configured and tested working. We have other alerts in this project with slack notifications that are managed by terraform and working.
I have the same situation. I try to import my alerts to terraform and get the following message:
error updating Alert Configuration information: PUT https://cloud.mongodb.com/api/atlas/v1.0/groups/<GROUPID>/alertConfigs/<ALERTID>: 500 (request "UNEXPECTED_ERROR") Unexpected error.
terraform --version Terraform v1.1.7
mongodbatlas = { source = "mongodb/mongodbatlas" version = "1.3.1" }
I opened a support case with mongo and was told this is a bug in the provider. Apparently their API was recently updated but the provider was not updated to match.
Not sure if this is only for the serverless alerts or all alert configurations.
Figured I'd update this issue since no one from mongo has commented here yet.
Hi @paivin-dn and @larntz this is not a bug per se. We have not yet implemented serverless alerts. Serverless is currently in preview mode (that's why to even use the Terraform provider to create a serverless deployment you have to use the beta env). We will add these new alert options soon, possibly before GA or shortly there after.
Internal ticket INTMDB-322
I attempted, and was unable to, reproduce the issue with the following configuration on v1.4.4
resource "mongodbatlas_serverless_instance" "test" {
project_id = var.project_id
name = var.serverless_name
provider_settings_backing_provider_name = "AWS"
provider_settings_provider_name = "SERVERLESS"
provider_settings_region_name = "US_EAST_1"
}
resource "mongodbatlas_alert_configuration" "outside_serverless_metric_threshold" {
enabled = true
event_type = "OUTSIDE_SERVERLESS_METRIC_THRESHOLD"
project_id = var.project_id
metric_threshold_config {
metric_name = "SERVERLESS_CONNECTIONS_PERCENT"
mode = "AVERAGE"
operator = "GREATER_THAN"
threshold = 80
units = "RAW"
}
notification {
type_name = "EMAIL"
email_address = var.notification_email_address
delay_min = 0
interval_min = 60
}
}
Is this still an issue?
Also, there's an in-review merge request aimed at improving the documentation around serverless alert_configurations https://github.com/mongodb/terraform-provider-mongodbatlas/pull/816
Thanks for following up on this issue!
I'm not sure if there is still an issue. I haven't tried this again with the newer providers. I will make a note to try it again as soon as I get a chance, but if you are unable to reproduce this with the newer versions I trust your testing.