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 244 forks source link

`newrelic_notification_destination` Data Source: sub-string search issue #2681

Closed getnilay closed 1 month ago

getnilay commented 1 month 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.

  required_version = ">= 1.8.2"

  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = "3.37.1"
    }
  }
}```

### Affected Resource(s)
Please list the resources as a list, for example:
- `newrelic_notification_destination` data sources

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.
```hcl
# Copy-paste your Terraform configurations here - for large Terraform configs,
data "newrelic_notification_destination" "data-notification-dest" {
  for_each = toset(concat(var.destinations))

  name = each.value
}

locals {
  destination_ids = {
    for k, v in data.newrelic_notification_destination.data-notification-dest : k => v.id
  }
}

output "destination_info" {
  value = {
    for k, v in local.destination_ids : k => {
      val = v
      key = k
    }
  }
}

# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our [GPG public key](https://github.com/newrelic/observability-as-code/blob/master/docs/developer-toolkit.asc).
# For more information on how to encrypt files check out the [GPG Privacy handbook](https://www.gnupg.org/gph/en/manual/x110.html).

Actual Behavior

What actually happened? Newrelic doesn't search for exact string and does a substring search. if there are 2 destination in Newrelic namely newrelic-prod-alerts and terraform-newrelic-prod-alerts and if you intend to search ONLY terraform-newrelic-prod-alerts it won't provide the destination id of the sourced but the other one, since it tends to perform a substring search.

Expected Behavior

What should have happened? Newrelic should perform an exact match and if multiple resources found return a list

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

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.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

pranav-new-relic commented 1 month ago

Thank you for reporting this, @getnilay.

This sounds like a duplicate of #2468 (a similar scenario has been described in this issue, as well). The team has been investigating into this and has work planned to address the same, which shall be picked up based on the current priority queue, and shall reach out to you for more information if necessary :)

pranav-new-relic commented 1 month ago

We shall be closing this issue, as the team shall be actively monitoring the aforementioned duplicate of the issue (#2468) that was created previously. Please follow the issue linked here :)

cc @amaor-newrelic