has anyone got auth working with the `@pulumi/newr...
# general
q
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
cc @stocky-spoon-28903
s
I have had it working - how are you specifying the key?
q
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
Can you try the environment variables?
NEWRELIC_API_KEY
q
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
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
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
Yes
q
well it's set on my local machine and then i just did a pulumi up
s
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
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
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
s
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
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
Iā€™m still waiting for a reply back from New Relic here
q
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
I will try again shortly! I still canā€™t repro the API key not being passed through AFAICT
q
hm okay, thanks for the help. i'm wondering what can be different between our environments since we're just setting environment variables
s
Is all well if you set the provider config explicitly in code with a first class provider?
q
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
Copy code
const nrprovider = new newrelic.Provider("somename", {
  apiKey: "whatever"
});
Iā€™m looking up the exact key, one sec
(updated above)
q
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
Aha
q
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
That is not intended. Iā€™ll investigate that one later today now thereā€™s a lead on what might be wrong
q
perfect, thanks again!
hello - any updates on this ticket? šŸ™‚