i have a question about the new relic package. I s...
# general
q
i have a question about the new relic package. I see that this was resolved https://github.com/pulumi/pulumi-newrelic/issues/1. but I dont think it resolved the issue. code sample in thread
Copy code
const nrprovider = new newrelic.Provider("bngo-test", { apiKey: "test" });

const fooAlertPolicy = new newrelic.AlertPolicy("foo", {});
const fooInfraAlertCondition = new newrelic.InfraAlertCondition("foo", {
    comparison: "above",
    critical: {
        duration: 25,
        timeFunction: "all",
        value: 90,
    },
    event: "StorageSample",
    policyId: 100,
    select: "diskUsedPercent",
    type: "infra_metric",
    where: "(`hostname` LIKE '%frontend%')",
}, {provider: nrprovider});
the error:
Copy code
Diagnostics:
  newrelic:index:AlertPolicy (foo):
    error: 1 error occurred:
    	* missing required configuration key "newrelic:apiKey":
    Set a value using the command `pulumi config set newrelic:apiKey <value>`.
b
@stocky-spoon-28903 ☝️
q
still doesn't look like the key i provide to the provider is being honored
s
I’ll take a look again in a few mins
q
thanks!
i have a long-ish meeting coming up shortly so my responses may be sparse
b
@quaint-queen-45003 are you around per chance?
q
yup!
b
So just to let you know, we are looking into your error right now!
It's definitely not acting as expected
Could you do me a favour and try and drop this part
Copy code
const nrprovider = new newrelic.Provider("bngo-test", { apiKey: "test" });
q
great! thanks for the help.
b
and then set
NEWRELIC_API_KEY
as an env var
and see if that works for you?
q
sure, so just have this?
Copy code
const fooAlertPolicy = new newrelic.AlertPolicy("foo", {});
const fooInfraAlertCondition = new newrelic.InfraAlertCondition("foo", {
    comparison: "above",
    critical: {
        duration: 25,
        timeFunction: "all",
        value: 90,
    },
    event: "StorageSample",
    policyId: 100,
    select: "diskUsedPercent",
    type: "infra_metric",
    where: "(`hostname` LIKE '%frontend%')",
});
b
yessir
I have a feeling that will work...
q
looks like it's taking a key now
Copy code
Diagnostics:
  newrelic:index:AlertPolicy (foo):
    error: could not validate provider configuration: 1 error occurred:
    	* : invalid or unknown key: key
now im just using the wrong key but that should be an easy fix on my side
hmm i just generated a new New Relic admin API. set the env variable and im still hitting this error though
b
interesting... ok this is helping me a lot! Thank you πŸ™‚
ok @quaint-queen-45003 you will be happy to know I found exactly the same error πŸ™‚
q
ha! glad im not entirely crazy
b
it definitely works when setting the key via ENV VAR
Copy code
β–Ά pulumi up
Previewing update (newrelic-test):

     Type                           Name                                 Plan
 +   pulumi:pulumi:Stack            alert-policy-newrelic-newrelic-test  create
 +   └─ newrelic:index:AlertPolicy  foo                                  create

Resources:
    + 2 to create

Do you want to perform this update? yes
Updating (newrelic-test):

     Type                           Name                                 Status
 +   pulumi:pulumi:Stack            alert-policy-newrelic-newrelic-test  created
 +   └─ newrelic:index:AlertPolicy  foo                                  created

Outputs:
    id: "460780"

Resources:
    + 2 created

Duration: 5s
q
interesting. i was hitting the error with a known working key and with the new admin api key that i just generated
b
are you on latest?
q
Copy code
pulumi version
v0.17.14
b
and the latest provider release?
q
0.18.1
b
ok, the same as me then
ok @quaint-queen-45003, instead of passing the key to the provider as EnvVar OR via the Provider registration, can you try this as a last step:
Copy code
pulumi config set newrelic:apiKey NOTAREALKEY
with your key of course!
q
Copy code
Diagnostics:
  newrelic:index:AlertPolicy (foo):
    error: could not validate provider configuration: 1 error occurred:
    	* : invalid or unknown key: key
when i try my known key and new admin key
b
huh!
this is so weird!
we are not getting that error here....
are you able to run pulumi in this mode
Copy code
pulumi preview -v=8 --logtostderr
and redirect stderr to a file
that way we can look more for you
q
let me know if yall need anything else
b
Thanks!
q
should i open new bug on this?
b
Hey @quaint-queen-45003 are you around?
Just wanted to give you a heads up that we are going to close your issue as it’s a configuration problem ;) I missed it all of this time and I’m pretty sure it will work for you when you see the solution Let me know if there are any other issues
q
hey paul - sorry for the late reply. I was out of the office on friday. I just re-attempted with the adjusted config and i think it works (at least got a different error πŸ™‚ )! Thanks for the help! i'm going to spend the day writing these alerts so i'll let you know if something comes up
thanks again!
b
πŸ‘
no worries at all
q
so far everything works pretty well. I have a question about
alertPolicyChannel
. The example provided in the code throws an error around
fooAlertChannel.id
and
fooAlertPolicy.id
. here's the sample code provided
Copy code
const fooAlertChannel = new newrelic.AlertChannel("foo", {
        configuration: {
            include_json_attachment: "1",
            recipients: "<mailto:foo@example.com|foo@example.com>",
        },
        type: "email",
    });
const fooAlertPolicy = new newrelic.AlertPolicy("foo", {});
const fooAlertPolicyChannel = new newrelic.AlertPolicyChannel("foo", {
    channelId: fooAlertChannel.id,
    policyId: fooAlertPolicy.id,
});
and here's the error
Copy code
Type 'Output<string>' is not assignable to type 'Input<number>'.
  Type 'Output<string>' is not assignable to type 'OutputInstance<number>'.
how should i reference
fooAlertChannel.id
and
fooAlertPolicy.id
?