Hi I'm rewriting my newrelic monitoring and notif...
# getting-started
p
Hi I'm rewriting my newrelic monitoring and notifications to pulumi. I want it simple as it can be SSL + ping monitoring. It's all paired nicely with notification emails from config. I did quick test code which works nicely for static destination confi. But since I want this dynamic for other people from company, I need a configurable list of emails (simple array of strings). However after switching to this, pulumi constantly detects changes, and wants to update destination ids in Workflow always. My code snippet for example:
Copy code
const notificationEmails: string[] = config.requireObject<string[]>("notificationEmails")
let destinationIds: any[] = [];

// building destinations IDs from email list:
notificationEmails.map((email: string) => {

    const alertDest = new newrelic.NotificationDestination(`${client}-alertDest-${email}`, {
        name: getNameWithConvention(`Alert ${email}`),
        type: 'EMAIL',
        active: true,
        properties: [
            {
                key: 'email',
                value: email,
            },
        ],
    });

    const alertChannel = new newrelic.NotificationChannel(`${client}-alertChannel-${email}`, {
        name: getNameWithConvention(`Alert channel`),
        destinationId: alertDest.id,
        product: "IINT",
        properties: [
        ],
        type: "EMAIL",
    });

    destinationIds.push({
        channelId: alertChannel.id,
    });
})

const alertNotificationWorkflow = new newrelic.Workflow("alertNotificationWorkflow", {
    name: `[${client}] Notification workflow`,
    mutingRulesHandling: "NOTIFY_ALL_ISSUES",
    issuesFilter: {
        name: "Filter-name",
        type: "FILTER",
        predicates: [{
            attribute: "labels.policyIds",
            operator: "EXACTLY_MATCHES",
            values: [
                alertPolicy.id
            ],
        }],
    },
    destinations: destinationIds,
});
And it always writes:
Copy code
Previewing update (dev):
     Type                        Name                         Plan       Info
     pulumi:pulumi:Stack         pulumi-newrelic-dev             
 ~   └─ newrelic:index:Workflow  alertNotificationWorkflow    update     [diff: ~destinations]
Of course running pulumi up is not helping, because after that it is still the same.
d
It's worth checking preview with
--diff
to get a more detailed view of what's changing. As for updating who gets emailed, I tend to setup mailing lists/groups for notifications, and manage the individuals on the group itself. Google Groups works nicely for this
p
I checked diff, but it's always the same, and shows change of order of elements in array of destination Ids...
Copy code
~ destinations: [
          ~ [0]: {
                  ~ channelId: "ID1" => "ID2"
                }
          ~ [1]: {
                  ~ channelId: "ID2" => "ID1"
                }
        ]
and it's always the same, after pulumi up, it saves, changes acording to that diff, but than change is not detected and diff is the same. Anyways - I like your idea with mailing groups, but I would need to manage mailing groups with pulumi as well ..., will need to dig into this, but it's interesting, Thanks
d
Can you report the issue to the provider, please? https://github.com/pulumi/pulumi-newrelic/issues Though this is likely a bug in the upstream tf provider. No one's mentioned it there yet: https://github.com/newrelic/terraform-provider-newrelic
p
ok, interesting I will report it there 🙂