terraform-provider-newrelic icon indicating copy to clipboard operation
terraform-provider-newrelic copied to clipboard

Error initializing newrelic-client-go when missing ENV variable

Open jamesgoodhouse opened this issue 4 years ago • 9 comments

When using the newrelic_insights_event resource, I am receiving an error when only setting the insights_insert_key via the environment variable NEW_RELIC_INSIGHTS_INSERT_KEY. If I set the api_key via the environment variable NEW_RELIC_API_KEY then things work as expected, even if that value I use is a junk value.

Terraform Version

0.13.5

Affected Resource(s)

  • newrelic_insights_event

Terraform Configuration

Provider has no configuration block in HCL and is instead configured using the following environment variables:

  • NEW_RELIC_ACCOUNT_ID
  • NEW_RELIC_INSIGHTS_INSERT_KEY
  • NEW_RELIC_INSIGHTS_INSERT_URL (necessary for my specific use-case but shouldn't be needed to replicate problem)
resource "newrelic_insights_event" "some_event" {
  event {
    type = "SomeEvenType"

    attribute {
      key = "some_attribute"
      value = "some value"
    }
  }
}

Actual Behavior

Terraform does not plan or apply and instead returns Error: error initializing newrelic-client-go: must use at least one of: ConfigPersonalAPIKey, ConfigAdminAPIKey, ConfigInsightsInsertKey.

Expected Behavior

Terraform should successfully plan and apply, as I am only interacting with the Insights API and shouldn't need to set a personal API key or admin API key.

Steps to Reproduce

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

  1. export NEW_RELIC_ACCOUNT_ID=1234
  2. export NEW_RELIC_INSIGHTS_INSERT_KEY=5678
  3. terraform init
  4. terraform plan

Debug Output

N/A

Panic Output

N/A

Important Factoids

N/A

References

N/A

jamesgoodhouse avatar Oct 30 '20 17:10 jamesgoodhouse

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Nov 13 '20 17:11 stale[bot]

Thanks for reporting James. Per your reproduction steps, I was able to reproduce this.

sanderblue avatar Nov 17 '20 18:11 sanderblue

I'll take this one as part of my onboarding on DTK.

jpvajda avatar Nov 17 '20 19:11 jpvajda

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Dec 03 '20 23:12 stale[bot]

Moving back to TO-DO as I was working with @sanderblue on it.

jpvajda avatar Dec 03 '20 23:12 jpvajda

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Dec 18 '20 01:12 stale[bot]

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jan 02 '21 21:01 stale[bot]

This issue has been automatically closed due to a lack of activity for an extended period of time.

stale[bot] avatar Jan 09 '21 21:01 stale[bot]

I'm running into this issue (or a similar one, anyway) as well:

Even if the api_key variable for the newrelic provider is set, e.g.:

provider "newrelic" {
  region     = "US"
  account_id = data.aws_s3_bucket_object.newrelic_account_id.body
  api_key    = data.aws_s3_bucket_object.newrelic_apikey.body
}

...Terraform will ignore it, and if NEW_RELIC_API_KEY is not declared, the exact same must use at least one of error message is thrown.

Tested on Terraform v0.13.5 and v.0.13.6; it'll be a bit before we can get our infra up to 14/15, but I imagine this might still apply with those.

bleachbyte avatar Apr 15 '21 05:04 bleachbyte