Skip to content

Unclear what account_id does, it seems to have no effect #1623

Open
@gitcos

Description

@gitcos

Created a small self-contained terraform configuration for a New Relic synthetic.
Put my REST API user key in environment variable NEW_RELIC_API_KEY.

When I run 'terraform apply' the synthetic is successfully created in the NR account associated with that REST API key.
However, it does not seem to matter if I put a different account's numeric ID as the account_id in the .tf file. Whatever account ID I put in the .tf file is ignored; the resources are always deployed to the account matching my API key. No warning is given of that does not match the account_id in the .tf file.

I experimented by using two different REST API keys, for two different NR accounts, and running terraform apply and terraform destroy with each key. For each key, I did the above with the correct account_id in the .tf file, and also with the other account's ID in the .tf file. In each case, the account_id did not have any apparent effect, and terraform always acted on the account associated with the API key I had in my environment at the time.

I did not have a NEW_RELIC_ACCOuNT_ID variable set, nor any other environment variables with "RELIC" in their name.

main.tf (with account ID redacted):

terraform {
  required_providers {
    newrelic = {
      source = "newrelic/newrelic"
    }
  }
}

provider "newrelic" {
  region = "us"
  account_id = xxxxxxx  # Numeric ID of New Relic account
}

resource "newrelic_synthetics_monitor" "example" {
  type      = "SCRIPT_API"
  name      = "Example"
  frequency = 10
  status    = "ENABLED"
  locations = ["AWS_US_EAST_1"]
}

resource "newrelic_synthetics_monitor_script" "example" {
  monitor_id = newrelic_synthetics_monitor.example.id
  text       = file("example_api_script.js")
}

% terraform -v
Terraform v1.1.4
on darwin_amd64

  • provider registry.terraform.io/newrelic/newrelic v2.35.1

Actual Behavior

Resources added or destroyed in NR account that does not match the account_id in the .tf file. No warning or error message.

Expected Behavior

Uncertain, because your documentation does not actually explain what effect account_id is supposed to have. My guess is that account_id should set which NR account terraform should act on. In that case, I would expect a clear error telling me that my API key does not give access to the account in question, and a failure. However, it is possible that account_id has some other meaning, and that would not be the right behavior.

One thing I do expect is much better documentation for the newrelic terraform provider. It is very thin and perfunctory and omits more than it covers. Many arguments and behaviors are not adequately documented. Your terraform provider documentation needs serious work; it is barely usable in its current state. While this bug highlights just one example, I have been frustrated repeatedly by omissions and ambiguities throughout this documentation.

https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/guides/provider_configuration just says that account_id is "Your New Relic account ID." and is required, and links to a page on how to find account IDs. It says nothing about what this argument is for, or what effect it should have. (The same can be said about most of the argument documentation on all pages in that reference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions