terraform-provider-newrelic: terraform apply fails on `newrelic_synthetics_multilocation_alert_condition`
Terraform Version
Terraform v1.4.5 on darwin_arm64
- provider registry.terraform.io/hashicorp/http v2.2.0
- provider registry.terraform.io/newrelic/newrelic v3.20.2
Affected Resource(s)
synthetics_multilocation_alert_condition
Terraform Configuration
terraform {
required_version = ">= 1.3.0"
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = "3.20.2"
}
http = {
source = "hashicorp/http"
version = "~>2"
}
}
backend "http" {}
}
provider "newrelic" {
alias = "non_prod"
account_id = var.nr_account_id_digitech_nonprod
api_key = var.nr_api_key_digitech_nonprod
region = var.nr_region
}
Actual Behavior
During the apply, provider failing with the next error:
newrelic_synthetics_multilocation_alert_condition.example: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to newrelic_synthetics_multilocation_alert_condition.example, provider "provider[\"registry.terraform.io/newrelic/newrelic\"].non_prod" produced
│ an unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
Expected Behavior
The resource should be created and successfully added to the state
Steps to Reproduce
I created a simple POC based on example from the documentation
main.tf
resource "newrelic_alert_policy" "policy" {
name = "debug-policy"
provider = newrelic.non_prod
}
resource "newrelic_synthetics_monitor" "monitor" {
provider = newrelic.non_prod
locations_public = ["US_WEST_1"]
name = "debug-monitor"
period = "EVERY_10_MINUTES"
status = "DISABLED"
type = "SIMPLE"
uri = "https://www.one.newrelic.com"
}
resource "newrelic_synthetics_multilocation_alert_condition" "example" {
provider = newrelic.non_prod
policy_id = newrelic_alert_policy.policy.id
name = "debug condition"
runbook_url = "https://example.com"
enabled = true
violation_time_limit_seconds = "3600"
entities = [
newrelic_synthetics_monitor.monitor.id
]
critical {
threshold = 2
}
}
Debug Output
https://gist.github.com/dehimb/bf5dbb567e41629b335afefd3be0f486
We can see, that request for the creation of the resource finished with 201 Created response Even if a resource was already created, API did not respond with an error. For each execution, it creates a new alert condition, which leads to duplication.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 28 (16 by maintainers)
Hi, a quick update - we’ve been able to reproduce this issue recently (unlike as previously mentioned with @dehimb in this thread), and identified this is an issue with the API that is failing to fetch the created multilocation_alert_conditon (though it succeeds to be created), leading to the error in Terraform. The same is happening when you explicitly try importing the created multilocation_alert_condition, owing to the same issue.
We’ve got in touch with the concerned team, who have acknowledged the issue with the API, and will soon plan on working on its fix. I shall keep you posted once the fix is out - thank you.
The fix was deployed to the API this Terraform Resource depends on, and is expected to have been mitigated in any current version of the Terraform Provider i.e. any version in which the error was found. However, you may choose to upgrade to the latest version released today, v3.22.0.
Hi, @pranav-new-relic Yes, i tried the mentioned procedure, and the code is similar to what i used for the tests. From the UI, we are specifying an aggregation window, and for the correct behavior, it should be the same, as the execution period of the synthetic check(to confirm two failed locations). So, the problem is the same
Hi @dehimb, thanks for confirming. We’ll take a look at this based on priority and reach back to you.