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

Data Source newrelic_key_transaction: Version 3.50.0 returns key transaction from incorrect New Relic account #2762

Open
garotinguyen opened this issue Oct 24, 2024 · 4 comments · Fixed by #2763

Comments

@garotinguyen
Copy link

garotinguyen commented Oct 24, 2024

Terraform Version

1.5.7

Provider Version

3.50.0

Affected Resource(s)

  • data newrelic_key_transaction

Terraform Configuration

this is a part of our terraform code used to deploy to our 4 environment/newrelic accounts. We will set appropriate API Key using environment variables.

  1. Have multiple Newrelic Accounts (we have 4 ones)
  2. Create KeyTransaction with the same name in all accounts
terraform {
  required_version = ">= 1.0"
  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = "= 3.50.0"
    }
  }
}

data "newrelic_key_transaction" "my_key_transaction" {
  name = "MyTransactionName"   # we have this name in all 4 newrelic accounts
}

output "my_key_transaction_id" {
  value = newrelic_key_transaction.my_key_transaction.id
}

# this is an example resource which will use 
resource "newrelic_alert_condition" "my_alert_condition" {
  policy_id = "a_policy_id"

  name     = "MyAlertCondition Apdex"
  type     = "apm_kt_metric"
  entities = [data.newrelic_key_transaction.my_key_transaction.id]
  metric   = "apdex"

  condition_scope = "application"

  term {
    duration      = 5
    operator      = "below"
    priority      = "critical"
    threshold     = "0.70"
    time_function = "all"
  }
}

Actual Behavior

  1. We have 4 KeyTransaction with the same name, say MyTransactionName, in 4 Newrelic Accounts (says Dev, Demo, Staging, and Prod)
  2. The problem was, when we deploying to an account, say Dev1 account, the provider will return the KeyTransanction of the other newrelic account consistently (instead of Dev1). It only happens to the KeyTransaction resource. And it only happens when using terraform because I did verify with a rest tool like postman and I could get the correct KeyTransaction item using the same API key set for terrform.
    And then because the KeyTransaction is not correct, it will fail to create any dependent resources, e.g. newrelic_alert_condition.my_alert_condition in the example terraform configuration above.

Expected Behavior

We expect the terraform provider should load KeyTransaction from the correct newrelic account (associated with the API key)

Steps to Reproduce

We found the problem with both terraform plan and terraform apply

Debug Output

No thing special. It outputs the incorrect value of the KeyTransaction.

@pranav-new-relic
Copy link
Member

pranav-new-relic commented Oct 24, 2024

Hi @garotinguyen, are you noticing this behaviour only with v3.50.0 and not with previous versions? This would help us debug the issue better, as we've recently changed the working of the newrelic_key_transaction data source to use NerdGraph instead of REST v2, starting v3.50.0. Thanks!

cc @vagrawal-newrelic

@garotinguyen
Copy link
Author

hi @pranav-new-relic I can confirm version 3.48 work correctly because we reverted back to 3.48 to fix the issue. I didn't test with 3.49 so I cannot tell.

@pranav-new-relic
Copy link
Member

@garotinguyen we just included a probable fix to this in our latest release (v3.51.0) as we were anyway going to release a version today :) can you please check if it works as desired now?

@pranav-new-relic pranav-new-relic changed the title version 3.50.0 return KeyTransaction from incorrect Newrelic Account when using data newrelic_key_transaction Data Source newrelic_key_transaction: Version 3.50.0 returns key transaction from incorrect New Relic account Oct 24, 2024
@garotinguyen
Copy link
Author

@pranav-new-relic thank you for the quick fix, we will give it a try next week and will let you know the result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants