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

Alert configuration state is not stable #632

Closed
guyguy333 opened this issue Dec 7, 2021 · 6 comments
Closed

Alert configuration state is not stable #632

guyguy333 opened this issue Dec 7, 2021 · 6 comments

Comments

@guyguy333
Copy link

Hello,

We use mongodbatlas_alert_configuration to setup our alerts with Opsgenie. It works fine. However, every time we plan / apply without any changes of HCL, terraform detects changes. Moreover, even if we apply, issue remains. I guess resource is not well set or state storing has an issue.

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform: 1.0.6
Provider Atlas: 1.1.1

Terraform Configuration File

resource "mongodbatlas_alert_configuration" "host_alerts" {
  for_each   = toset(["HOST_DOWN", "NO_PRIMARY", "HOST_MONGOT_CRASHING_OOM"])
  project_id = var.project_id
  event_type = each.key
  enabled    = true

  notification {
    ops_genie_api_key = var.api_token
    ops_genie_region  = "EU"
    type_name         = "OPS_GENIE"
    interval_min      = 5
    delay_min         = 0
    sms_enabled       = false
    email_enabled     = true
    roles             = ["GROUP_CHARTS_ADMIN", "GROUP_CLUSTER_MANAGER"]
  }
}

As we can see, email_enabled is set as well as interval_min and roles.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Expected Behavior

interval_min is set as well as email_enabled and roles and a plan/apply doesn't trigger changes after change has been set.

Actual Behavior

resource "mongodbatlas_alert_configuration" "host_alerts" {
        id                     = "xxxxxx"
        # (6 unchanged attributes hidden)

      ~ notification {
          ~ email_enabled          = false -> true
          ~ interval_min           = 0 -> 5
          ~ roles                  = [
              + "GROUP_CHARTS_ADMIN",
              + "GROUP_CLUSTER_MANAGER",
            ]
            # (19 unchanged attributes hidden)
        }
    }

Debug Output

Crash Output

Additional Context

References

@themantissa
Copy link
Collaborator

@guyguy333 let me have the team take a look.

@themantissa
Copy link
Collaborator

Internal ticket INTMDB-284

@themantissa
Copy link
Collaborator

@guyguy333 we determined the root cause. You cannot include both sms_enabled and email_enabled unless type_name is GROUP, ORG, or USER. The API will accept the parameters without error but it's why the state mismatches later. However the documentation is unclear on this so we will update that.

@guyguy333
Copy link
Author

Thanks @themantissa. I read the updated documentation in PR. So yes, in that case, as we're using Opsgenie, we can remove both fields sms_enabled and email_enabled. It now ends with:

~ notification {
          ~ interval_min           = 0 -> 5
          ~ roles                  = [
              + "GROUP_CHARTS_ADMIN",
              + "GROUP_CLUSTER_MANAGER",
            ]
            # (20 unchanged attributes hidden)
        }

I think I understand roles issue according to updated documentation and if I understand right, it has no impact for Opsgenie and so should be removed. However, for interval_min, I don't get why this diff is remaining:

notification {
          ~ interval_min           = 0 -> 5
            # (21 unchanged attributes hidden)
        }

resource "mongodbatlas_alert_configuration" "host_alerts" {
 for_each   = toset(["HOST_DOWN", "NO_PRIMARY", "HOST_MONGOT_CRASHING_OOM"])
 project_id = var.project_id
 event_type = each.key
 enabled    = true

 notification {
   ops_genie_api_key = var.api_token
   ops_genie_region  = "EU"
   type_name         = "OPS_GENIE"
   interval_min      = 5
   delay_min         = 0
 }
}

Thanks

@themantissa
Copy link
Collaborator

@guyguy333 that's actually a slightly different issue corrected in #624. Will be included in the next release.

@themantissa
Copy link
Collaborator

Fixed in 1.2

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

2 participants