New Relic - Terraform Error: the name does not match any New Relic alert channel

Hi guys, I am trying to setup New Relic monitoring via terraform using the following guide:

I have stored my admin api key as an environment variable.

I am receiving the following error after Terraform plan:


Any help is greatly appreciated.

Thanks for the question Dean. From looking at your example and the error message it appears that the Terraform provider is not able to find an existing New Relic Alert Channel with the name “RSO_Application_Services”. If that channel does not already exist, you’ll need to create it as a Terraform ‘resource’ instead of ‘data’. If it does exist, please make sure that the name argument is exact as it appears in the New Relic UI, and that it’s on the same account as the configured API key used when running terraform. Let us know if we can help further!


Hi @Dean.mullarkey! Were you able to get this working?

I’m seeing this error but with a different set up. More details on the github.

The resource is being created in one module and then the data is referencing it in a separate module. The names for the resource and data match but the plan fails. Terraform allows for data to behave differently as in the data sources docs. Ideally this would be handled where: “Query constraint arguments may refer to values that cannot be determined until after configuration is applied”

The configuration generally looks like this:

Where within the newrelic module I have the empty variable:

`- newrelic
`- service-a
`- service-b

In the newrelic module we have:

variable "service" {
  default = "value"

resource "newrelic_alert_policy" "incident-policy" {
  name                = "${var.service} INCIDENT"
  channel_ids         = [var.channel_id]
  incident_preference = "PER_CONDITION_AND_TARGET"


And in service-a, I have the value created and pass it into the module block:

locals {
  service = "TEAM"

module "newrelic" {
  source         = "../newrelic"
  service = local.service

data "newrelic_alert_policy" "incident" {
  name = "${local.service} INCIDENT"

this fails with the error:

Error: the name 'TEAM INCIDENT ' does not match any New Relic alert policy

[81] on service-ime/ line 22, in data "newrelic_alert_policy" "inc":

[82] 22: data "newrelic_alert_policy" "inc" {

@jthurman or @ctrombley Would one of you be able to work with @mmalave on the error their seeing?

I’ve followed up on gitbhub and it seems this is expected behavior:

@mmalave Thanks for the update :slight_smile: