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

[Bug]: Removing mongodbatlas_alert_configuration resource block after Alert was deleted manually in UI results in 401 Unauthorized Error in Subsequent Plan #2264

Open
2 tasks done
l-alfaro opened this issue May 9, 2024 · 4 comments
Labels

Comments

@l-alfaro
Copy link

l-alfaro commented May 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Provider Version

v1.16.0

Terraform Version

v1.6.2 (OpenTofu)

Terraform Edition

Terraform Open Source (OSS)

Current Behavior

We are getting the following error in our plans after removing the alert configuration to address a drift result:

│ Error: error getting Alert Configuration information: %s
│ 
│ https://cloud.mongodb.com/api/atlas/v2/groups/xxxxxxxxxxxxxxx/alertConfigs/xxxxxxxxxxxxxxxxxxxx
│ GET: HTTP 401 Unauthorized (Error code: "") Detail: You are not authorized
│ for this resource. Reason: Unauthorized. Params: []

The removal of the resource is the only change being made. Adding it back results in the plan succeeding again.

Terraform configuration to reproduce the issue

resource "mongodbatlas_alert_configuration" "alert_5" {
  enabled    = true
  event_type = "OUTSIDE_METRIC_THRESHOLD"
  project_id = data.mongodbatlas_project.project.id
  metric_threshold_config {
    metric_name = "DISK_PARTITION_UTILIZATION_DATA"
    mode        = "AVERAGE"
    operator    = "GREATER_THAN"
    threshold   = 90
    units       = "RAW"
  }
  notification {
    api_token                   = null # sensitive
    channel_name                = null
    datadog_api_key             = null # sensitive
    datadog_region              = null
    delay_min                   = 0
    email_address               = null
    email_enabled               = true
    interval_min                = 60
    microsoft_teams_webhook_url = null # sensitive
    mobile_number               = null
    notifier_id                 = "xxxxxxxxxxxxxxxxxxxx"
    ops_genie_api_key           = null # sensitive
    ops_genie_region            = null
    roles                       = ["GROUP_OWNER"]
    service_key                 = null # sensitive
    sms_enabled                 = false
    team_id                     = null
    type_name                   = "GROUP"
    username                    = null
    victor_ops_api_key          = null # sensitive
    victor_ops_routing_key      = null # sensitive
    webhook_secret              = null # sensitive
    webhook_url                 = null # sensitive
  }
}

Steps To Reproduce

  1. Delete alert from Cloud UI
  2. Run a new plan. Notice a new resource will be added for the alert
  3. Delete mongodbatlas_alert_configuration resource block form TF code
  4. Run a new plan. Notice 401 error and failed plan

Logs

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Copy link
Contributor

github-actions bot commented May 9, 2024

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

  • Terraform configuration file used to reproduce the issue
  • Terraform log files from the run where the issue occurred
  • Terraform Atlas provider version used to reproduce the issue
  • Terraform version used to reproduce the issue
  • Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment

The ticket CLOUDP-248530 was created for internal tracking.

Copy link
Contributor

This issue has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

@github-actions github-actions bot added the stale label May 15, 2024
@marcosuma
Copy link
Collaborator

Hi @l-alfaro thanks for opening this issue with us. Just so I understand correctly: is this error happening when you are trying to delete the alert configuration from the TF script?
Was that same alert configuration created through TF as well?

What the error is indicating is that it might be that you used different keys to create these alerts. I haven't tried to replicate locally, I'll wait for more updates before trying

@github-actions github-actions bot removed the stale label May 17, 2024
Copy link
Contributor

This issue has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

@github-actions github-actions bot added the stale label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants