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

email_enabled always reported as a change for mongodbatlas_alert_configuration #306

Closed
MartinCanovas opened this issue Sep 4, 2020 · 5 comments

Comments

@MartinCanovas
Copy link
Contributor

MartinCanovas commented Sep 4, 2020

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v0.12.26
+ provider.mongodbatlas v0.6.4

Terraform Configuration File

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_enabled = true
    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"
  }
}

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. Alert is created without issues. However next time you run 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 Output

Crash Output

Additional Context

References

@MartinCanovas
Copy link
Contributor Author

debug.log

@themantissa themantissa added the non-blocking bug Small fixes to doc or code that don't impede use. label Sep 4, 2020
@themantissa
Copy link
Collaborator

Thank you @MartinCanovas! We'll add this to the list to address.

@nikhil-mongo
Copy link
Collaborator

nikhil-mongo commented Sep 10, 2020

@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.

@MartinCanovas
Copy link
Contributor Author

@nikhil-mongo Excellent! Thanks for clarifying that, and my apologies for reporting this as a bug when it isn't.

@themantissa themantissa removed the non-blocking bug Small fixes to doc or code that don't impede use. label Sep 30, 2020
@themantissa
Copy link
Collaborator

Good catch @nikhil-mongo - I'll close this since resolved.

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

No branches or pull requests

3 participants