Closed MartinCanovas closed 4 years ago
Thank you @MartinCanovas! We'll add this to the list to address.
@MartinCanovas
As per the notifications.[n].emailEnabled
section of the Atlas API email_enabled =true
is only required in case the notification type is GROUP, ORG, or USER. This is why the terraform.tfstate file stores this value as email_enabled =false
. When you run plan
and the state file refreshes with the real-world and configuration does not matches and thus it shows you the plan changes.
Therefore, the correct terraform config would be -
resource "mongodbatlas_alert_configuration" "alert1" {
project_id = var.project_id
event_type = "OUTSIDE_METRIC_THRESHOLD"
enabled = true
notification {
type_name = "EMAIL"
interval_min = 5
delay_min = 0
sms_enabled = false
email_address = var.email_address
}
matcher {
field_name = "HOSTNAME_AND_PORT"
operator = "EQUALS"
value = "SECONDARY"
}
metric_threshold = {
metric_name = "ASSERT_REGULAR"
operator = "GREATER_THAN"
threshold = 70.0
units = "RAW"
mode = "AVERAGE"
}
}
This way terraform plan will not show changes everytime and thus this issue can be closed as it is not a bug.
@nikhil-mongo Excellent! Thanks for clarifying that, and my apologies for reporting this as a bug when it isn't.
Good catch @nikhil-mongo - I'll close this since resolved.
Terraform CLI and Terraform MongoDB Atlas Provider Version
Terraform Configuration File
Steps to Reproduce
terraform init
terraform apply
terraform apply
without any changes on the code, terraform will report in the Plan a change for the alert configuration:~ notification { delay_min = 0 email_address = "xxxxxxxxxxx" ~ email_enabled = false -> true interval_min = 5 roles = [] sms_enabled = false type_name = "EMAIL" } Plan: 0 to add, 1 to change, 0 to destroy.
Expected Behavior
Plan: 0 to add, 0 to change, 0 to destroy. ### Actual Behavior Plan: 0 to add, 1 to change, 0 to destroy. ### Debug OutputCrash Output
Additional Context
References