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

Resource newrelic_notification_destination: Creation fails with type error #2746

Open
6 tasks done
VenelinMartinov opened this issue Sep 11, 2024 · 5 comments
Open
6 tasks done

Comments

@VenelinMartinov
Copy link

VenelinMartinov commented Sep 11, 2024

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

⚠️ 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.

v1.9.5

Affected Resource(s)

Please list the resources as a list, for example:

  • newrelic_notification_destination

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 = "~> 1.0"
  required_providers {
    newrelic = {
      source = "newrelic/newrelic"
    }
  }
}



resource "newrelic_notification_destination" "foo" {
  account_id = 12345678
  name       = "foo"
  type       = "WEBHOOK"

  secure_url {
    prefix        = "https://webhook.mywebhook.com/"
    secure_suffix = "service_id/123456"
  }

  property {
    key   = "source"
    value = "terraform"
  }
}

Actual Behavior

What actually happened?

Creation fails with:

Plan: 1 to add, 0 to change, 0 to destroy.
newrelic_notification_destination.foo: Creating...
╷
│ Error: Access restricted
│
│   with newrelic_notification_destination.foo,
│   on main.tf line 12, in resource "newrelic_notification_destination" "foo":
│   12: resource "newrelic_notification_destination" "foo" {
│
│ NOTICE: fields are statically typed. Make sure all fields are of the correct type
╵
Error: exit status 1

Expected Behavior

What should have happened?
Creation succeeds or prints an actionable error

Steps to Reproduce

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

  1. terraform apply

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 pranav-new-relic changed the title newrelic_notification_destination creation fails with type error Resource newrelic_notification_destination: Creation fails with type error Sep 16, 2024
@pranav-new-relic
Copy link
Member

Hi @VenelinMartinov, I've had a word with my team, and it appears that this is an access issue surfacing from the API (the error thrown by the API is being shown by the Terraform Provider). Can you try creating other resources such as alerts, dashboards, workflows etc. with the same credentials and let us know if you're seeing this issue only with the resource you've reported this with? If this isn't the case and you're seeing similar access restricted errors with other resources too, you might need to use an active, right set of credentials; if not, and you're seeing the issue only with this resource, I'll see what we can do about this issue further. Thanks!

@VenelinMartinov
Copy link
Author

Hey @pranav-new-relic, thanks for getting back to me. It seems to be specific to the resource. I could run the following code fine with the same set of credentials:

terraform {
  required_version = "~> 1.0"
  required_providers {
    newrelic = {
      source = "newrelic/newrelic"
    }
  }
}

resource "newrelic_alert_policy" "foo" {
  name = "example"
  incident_preference = "PER_POLICY" # PER_POLICY is default
}

@dcristobalhMad
Copy link

dcristobalhMad commented Oct 9, 2024

Same issue here

NOTICE: fields are statically typed. Make sure all fields are of the correct type

Terraform v1.9.7
on darwin_arm64
+ provider registry.terraform.io/newrelic/newrelic v3.46.0

@buzzyboyyy
Copy link

@VenelinMartinov @dcristobalhMad I just ran into this same issue and found that including account_id in the newrelic_notification_destination resource was the culprit. After some troubleshooting, I removed account_id and referenced it via ssm param in the provider block and I got a successful apply. You can also just drop the account_id value in the provider block without a data lookup, my team just requires any unique identifiers to be ssm params or secrets.

example:

provider "newrelic" {
  account_id = data.aws_ssm_parameter.new_relic_account_id.value
  api_key    = data.aws_ssm_parameter.new_relic_api_key.value
  region     = "US"
}

@dcristobalhMad
Copy link

Hey 👋 @buzzyboyyy thanks for that! Now it is working. Anyway I would say it seems a bug in the provider

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

No branches or pull requests

4 participants