mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
241 stars 167 forks source link

After manually deletion of a billing alert, no more plan oder apply will succeed, becuase of an 404 during plan #305

Closed ckuetbach closed 3 years ago

ckuetbach commented 4 years ago

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v0.12.21
Atlasplugin 0.6.4

Terraform Configuration File

resource "mongodbatlas_alert_configuration" "billing_above_max" {
  project_id   =  <project-id>
  event_type = "PENDING_INVOICE_OVER_THRESHOLD"
  enabled    = true

  threshold = {
    threshold = 10
    operator = "GREATER_THAN"
    unit = "RAW"
  }

  notification {
    type_name     = "EMAIL"
    interval_min  = 60
    delay_min     = 0
    email_address  = "ckuetbach@gmail.com"
  }

}

Steps to Reproduce

Expected Behavior

Actual Behavior

Additional Infos

themantissa commented 4 years ago

@ckuetbach in repo steps was a refresh performed to refresh the state from the current system? Could you provide debug logs so we can see the specifics?

ckuetbach commented 4 years ago

I don't have the debug logs ready.

But there was a terraform refresh, before I made the changes, because I made an update from 0.5.1 to 0.6.4 to enable billing alert feature.

I'm not sure, how to create a debug log, do you have any documentation ready?

For me it looks, as if the provider won't check the current state correctly against the atlas API. this would explain the 404, while reading the state and also the fact it woldn't update some of the values, if changed (like amount).

I'll try to make a repro in debug mode.

nikhil-mongo commented 4 years ago

debug.log

Here is the debug file for this issue. The Atlas API responses with 404 all the time if any other service is deleted from UI too. But, this is not expected behaviour for billing as @ckuetbach mentioned. If this happens with Atlas cluster, as an exmaple, we create a new cluster rather than showing 404 error. We definitely need to look into this.

Thanks.

ckuetbach commented 4 years ago

@nikhil-mongo thanks a lot. Some changes in made with the UI aren't reflected by terraform. Lets say, you change the alert in the UI from monthly to daily (with amounts), but terraform says, all is up to date.

nikhil-mongo commented 4 years ago

@ckuetbach As per the eventTypeName in the Condition section of Atlas API, the billing event_type is different for all the 3 options. But as we have seen that the alerts are being managed using the alert_configuration_id and we have seen issues managing it. So, we believe that taking care of the alert section will help us configure this as well.

Attaching the debug.log file as the terraform refresh does finds the change in eventTypeName but does not shows it as a change.

debug.log

themantissa commented 4 years ago

@nikhil-mongo can you create an internal bug ticket for this? PRODTRIAGE and I'll move to the appropriate queue.

themantissa commented 3 years ago

Internal ID: INTMDB-112

themantissa commented 3 years ago

Fix was included in 0.7.0, closing issue.