https://pulumi.com logo
q

quaint-queen-45003

04/22/2019, 8:06 PM
has anyone got auth working with the
@pulumi/newrelic
package? I'm hitting errors like this
error: Plan apply failed: The API key provided is invalid
.
w

white-balloon-205

04/22/2019, 8:07 PM
cc @stocky-spoon-28903
s

stocky-spoon-28903

04/22/2019, 8:07 PM
I have had it working - how are you specifying the key?
q

quaint-queen-45003

04/22/2019, 8:08 PM
that's the part im trying to figure out, do you have an example that I can work off of?
i've been trying different variations of
Copy code
const newRelic = new newrelic.Provider("newRelic", {
    apiKey: newRelicApiKey
})
export const fooAlertChannel = pulumi.output(newrelic.getAlertChannel({
         name: "<mailto:foo@example.com|foo@example.com>",
}));
but haven't had any luck
this doesn't seem to work either:
Copy code
let nr = new newrelic.Provider("test", {apiKey: "api-key"});

export const fooAlertChannel = pulumi.output(newrelic.getAlertChannel({
         name: "<mailto:foo@example.com|foo@example.com>",
}));
(api key was redacted from this snippet)
s

stocky-spoon-28903

04/22/2019, 9:13 PM
Can you try the environment variables?
NEWRELIC_API_KEY
q

quaint-queen-45003

04/22/2019, 9:18 PM
i set the env variable. then trimmed down my script to only run
Copy code
export const fooAlertChannel = pulumi.output(newrelic.getAlertChannel({
         name: "bngo"
}));
and im still hitting an error with the api key 😞
Copy code
Error: invocation of newrelic:index/getAlertChannel:getAlertChannel returned an error: invoking newrelic:index/getAlertChannel:getAlertChannel: The API key provided is invalid
s

stocky-spoon-28903

04/22/2019, 9:25 PM
Hmm, let me test this with the latest version of the package.
I get a different error which implies a valid API key being transmitted, telling me my subscription doesn’t have access to alerts (which is true)
q

quaint-queen-45003

04/22/2019, 9:48 PM
did you set it as an environment variable?
i've got
NEWRELIC_API_KEY=
set to a known working key so i wonder where it's getting tripped up 🤔
s

stocky-spoon-28903

04/22/2019, 9:49 PM
Yes
q

quaint-queen-45003

04/22/2019, 9:50 PM
well it's set on my local machine and then i just did a pulumi up
s

stocky-spoon-28903

04/22/2019, 9:53 PM
This is weird. I want to confirm it actually gets further, but we need our account upgrading to be able to test this. @white-balloon-205 I’ve added you and @big-piano-35669 as admins using your pulumi emails - could you upgrade it or nominate someone who can so we can get to the bottom of this?
@quaint-queen-45003 All I have is
NEWRELIC_API_KEY
set and it works here. Once we get the account upgraded at this end I’ll come back to you for further debugging
q

quaint-queen-45003

04/22/2019, 9:55 PM
hmm that's so odd that it's not working but thank you for your help so far!
should i open an issue on github?
s

stocky-spoon-28903

04/22/2019, 10:02 PM
We’re investigating it now - feel free to open an issue though and I’ll follow up on there if you’re not online when I get back to it
q

quaint-queen-45003

04/22/2019, 10:33 PM
s

stocky-spoon-28903

04/22/2019, 11:57 PM
Hi @quaint-queen-45003 - I can’t repro getting “Invalid token” with an actually valid token (though can with random text). Unfortunately New Relic is not particularly transparent as to what package you need to have API access to alerts to test your program properly, and their support system won’t let me open a ticket, replying “Whoops, there’s a problem” instead. I’m waiting on their sales person to explain what I need, and will follow up once I have that.
One thing worth testing is whether you can use your token successfully with an equivalent Terraform configuration?
(I can write one for you if you don’t already have one)
q

quaint-queen-45003

04/23/2019, 3:57 PM
i don't have any TF written for this but I can see if I can spin something up this morning. This token has worked for us previously in helm charts so that shouldn't be an issue
i have some ideas as to what might be going on. I'll try a few things and let you know if I get something worked out. thanks again for the help!
i created a new Account Admin user type and generated a new key. it didn't work via pulumi 😞
s

stocky-spoon-28903

04/23/2019, 7:26 PM
I’m still waiting for a reply back from New Relic here
q

quaint-queen-45003

04/23/2019, 7:47 PM
sounds good. is there any way explicitly pass in a key? sort of like this in TF:
Copy code
# Configure the New Relic provider
provider "newrelic" {
  api_key = "${var.newrelic_api_key}"
}
any updates? 🙂
s

stocky-spoon-28903

05/06/2019, 10:52 PM
I will try again shortly! I still can’t repro the API key not being passed through AFAICT
q

quaint-queen-45003

05/06/2019, 10:56 PM
hm okay, thanks for the help. i'm wondering what can be different between our environments since we're just setting environment variables
s

stocky-spoon-28903

05/06/2019, 10:58 PM
Is all well if you set the provider config explicitly in code with a first class provider?
q

quaint-queen-45003

05/06/2019, 10:58 PM
i wasn't able to figure out how to do that via pulumi
i couldn't figure out how to explicitly set the key via code
s

stocky-spoon-28903

05/06/2019, 11:02 PM
Copy code
const nrprovider = new newrelic.Provider("somename", {
  apiKey: "whatever"
});
I’m looking up the exact key, one sec
(updated above)
q

quaint-queen-45003

05/07/2019, 5:07 PM
i think i see what's happening. the im hitting this error now
error: Missing required configuration variable 'newrelic:apiKey'
pulumi config
shows that I have my key set as
newrelic:key
rather than
newrelic:apiKey
s

stocky-spoon-28903

05/07/2019, 5:09 PM
Aha
q

quaint-queen-45003

05/07/2019, 5:10 PM
if i hard code the actual key it fails or point to
newrelic:key
it fails
odd that it doesn't even accept the value when it's hard coded
so it doesn't appear to matter if i pass in
apiKey
to the provider or not
if i hard code it or pass in an empty string it'll still read
newrelic:apiKey
from pulumi config
is that intended? i'd assume it should use the string that i pass in rather than reading from
pulumi config
s

stocky-spoon-28903

05/07/2019, 5:15 PM
That is not intended. I’ll investigate that one later today now there’s a lead on what might be wrong
q

quaint-queen-45003

05/07/2019, 5:19 PM
perfect, thanks again!
hello - any updates on this ticket? 🙂