newrelic / terraform-provider-newrelic

Terraform provider for New Relic
https://registry.terraform.io/providers/newrelic/newrelic/latest/docs
Mozilla Public License 2.0
200 stars 247 forks source link

`newrelic_alert_policy_channel` creation giving an `Error: DELETE https://api.newrelic.com/v2/alerts_policy_channels.json giving up after 4 attempt(s)` #1923

Closed jcstryker closed 2 years ago

jcstryker commented 2 years ago

Hi there,

Thank you for opening an issue. In order to better assist you with your issue, we kindly ask to follow the template format and instructions. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests only. General usage questions submitted as issues will be closed and redirected to New Relic's Explorers Hub https://discuss.newrelic.com/c/build-on-new-relic/developer-toolkit.

Please include the following with your bug report

:warning: Important: Failure to include the following, such as omitting the Terraform configuration in question, may delay resolving the issue.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v1.2.0

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration

Please include your provider configuration (sensitive details redacted) as well as the configuration of the resources and/or data sources related to the bug report.


terraform {
required_version = ">= 0.15.0"
required_providers {
newrelic = {
source  = "newrelic/newrelic"
version = "~> 2.49.1"
}
}
}
provider "newrelic" {
account_id = var.newrelicAccountID
api_key    = var.newrelic_api_key
region     = var.newrelic_region
}

Applies the created channels above to the alert policy

resource "newrelic_alert_policy_channel" "redacted" { count = local.pagerduty_enabled || local.slack_enabled ? 1 : 0 policy_id = newrelic_alert_policy.redacted.id

channel_ids = [ for i, channel in concat(newrelic_alert_channel.pagerduty_channel, newrelic_alert_channel.slack_channel) : channel.id ] }


### Actual Behavior
What actually happened?

Running `terraform destroy` results in this error message:

Error: DELETE https://api.newrelic.com/v2/alerts_policy_channels.json? giving up after 4 attempt(s)



### Expected Behavior
What should have happened?

The generated `newrelic_alert_policy_channel` should be removed.

### Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
1. `terraform destroy`

### Debug Output
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

### References
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
Seems very similar to https://github.com/newrelic/terraform-provider-newrelic/issues/1912
shiva-bandari commented 2 years ago

Hi @jcstryker,
Thanks for raising the issues. We will reproduce the issues and get back to you.

henrymegwai commented 2 years ago

@jcstryker I am also currently having the exact same issue. Looking forward to a resolution soon. Thanks!

Screenshot 2022-08-10 at 15 08 18
OllyNural commented 2 years ago

Am also seeing this with provider version 2.44.0

resource "newrelic_alert_policy_channel" "keymoments_channels" {
  policy_id   = newrelic_alert_policy.keymoments.id
  channel_ids = [newrelic_alert_channel.keymoments_alerts.id]
}

resource "newrelic_alert_policy" "keymoments" {
  name                = "Keymoments"
  incident_preference = "PER_CONDITION"
}

resource "newrelic_alert_channel" "alerts_channel" {
  name = "Alert Notification Channel"
  type = "webhook"
  config {
    base_url       = local.teams_newrelic_webhook
    payload_type   = "application/json"
    payload_string = <<EOF
       ....
    EOF
  }
}
Sarang-Dharme-od commented 2 years ago

Hello @jcstryker @shiva-bandari +1 to this issue. I am getting this error while deleting opsgenie notification channel from alerting policy. image

Provider :newrelic/newrelic v2.49.1

Code: Variables.tf

variable "add_opsgenie" { type = bool default = false }

Main.tf

resource "newrelic_alert_channel" "terraform_opsgenie_channel" { count = var.add_opsgenie ? 1 : 0 name = "terraform_opsgenie_channel" type = "opsgenie"

config { api_key = "abcdefgh" teams = "Terraform-Opsgenie-Test1" } }

resource "newrelic_alert_policy_channel" "terraform_alert_channel-opsgenie" { count = var.add_opsgenie ? 1 : 0 policy_id = newrelic_alert_policy.terrafrom_alert_test_policy.id channel_ids = [newrelic_alert_channel.terraform_opsgenie_channel[0].id] } Thanks!

kidk commented 2 years ago

Thanks all. I'm wondering if this is still an ongoing issue? We've had some incidents relating to alerts recently.

Malhujaj commented 2 years ago

Hi i had this issue a while back I first encountered it about 7 days ago but the issue seems to have gone away for me at least, everything seems to be working fine now.

kidk commented 2 years ago

Thanks @Malhujaj I'll leave it open for another week, but it looks like this has resolved itself.