pulumi / pulumi-pagerduty

A PagerDuty Pulumi resource package, providing multi-language access to PagerDuty
Apache License 2.0
8 stars 2 forks source link

Updates/previews want to reorder the `events` property for WebhookSubscription #625

Open MitchellGerdisch opened 1 month ago

MitchellGerdisch commented 1 month ago

Describe what happened

When running pulumi up or preview for a program that includes a pagerduty WebhookSubscription resource with a list of events specified (https://www.pulumi.com/registry/packages/pagerduty/api-docs/webhooksubscription/#events_nodejs) even though nothing has changed, pulumi shows a diff and wants to update the resource due to the events list property being reordered by the provider.

This results in a diff like this. Although a work-around may be to sort the events in alphabetical order to match what the provider or API returns, it seems like this should not be necessary and it should just work.

~ pagerduty:index/webhookSubscription:WebhookSubscription: (update)
        [urn=urn:pulumi:infra::pagerduty:index/webhookSubscription:WebhookSubscription::service-webhookSubscription]
        [provider=urn:pulumi:infra::pulumi:providers:pagerduty::pagerduty-webhook-provider::dbdafs-bc98-4d8b-9c19-ad97919a00b6]
      ~ events: [
          ~ [0]: "incident.acknowledged" => "incident.triggered"
          ~ [1]: "incident.delegated" => "incident.acknowledged"
          ~ [2]: "incident.resolved" => "incident.unacknowledged"
          ~ [3]: "incident.triggered" => "incident.delegated"
          ~ [4]: "incident.unacknowledged" => "incident.resolved"
        ]

Sample program

To reproduce, run pulumi up twice or more times for the following program. You will see that the second and later updates always show a diff because the acknowledged event is out of alphabetical order.

import * as pulumi from "@pulumi/pulumi";
import * as pagerduty from "@pulumi/pagerduty";

const example = pagerduty.getService({
    name: "MyDummy",
});
const foo = new pagerduty.WebhookSubscription("foo", {
    deliveryMethods: [{
        type: "http_delivery_method",
        url: "https://example.com/receive_a_pagerduty_webhook",
        customHeaders: [
            {
                name: "X-Foo",
                value: "foo",
            },
            {
                name: "X-Bar",
                value: "bar",
            },
        ],
    }],
    description: "%s",
    events: [
        "incident.annotated",
        "incident.acknowledged",
        "incident.delegated",
        "incident.escalated",
        "incident.priority_updated",
        "incident.reassigned",
        "incident.reopened",
        "incident.resolved",
        "incident.responder.added",
        "incident.responder.replied",
        "incident.status_update_published",
        "incident.triggered",
        "incident.unacknowledged",
    ],
    active: true,
    filters: [{
        id: example.then(example => example.id),
        type: "service_reference",
    }],
    type: "webhook_subscription",
});

Log output

No response

Affected Resource(s)

No response

Output of pulumi about

CLI
Version 3.134.1 Go Version go1.23.1 Go Compiler gc

Plugins KIND NAME VERSION language nodejs unknown resource pagerduty 4.14.6

Host
OS darwin Version 13.6.9 Arch x86_64

This project is written in nodejs: executable='/Users/mitch/.nvm/versions/node/v20.10.0/bin/node' version='v20.10.0'

Found no resources associated with dev

Found no pending operations associated with dev

Backend
Name pulumi.com

Dependencies: NAME VERSION @pulumi/pagerduty 4.14.6 @pulumi/pulumi 3.134.1 @types/node 18.19.54 typescript 5.6.2

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

MitchellGerdisch commented 1 month ago

FYI, This also happens with Python.

VenelinMartinov commented 1 month ago

Thanks for reporting @MitchellGerdisch, I've reproduced this upstream and raised an issue: https://github.com/PagerDuty/terraform-provider-pagerduty/issues/934

For anyone affected, the workaround as @MitchellGerdisch noted is to rearrange the property inputs to be alphabetical.

joeduffy commented 1 month ago

@VenelinMartinov Is the upstream bug correct? It looks like the template, not the actual issue, in the body of the issue, unless I’m misunderstanding something.

VenelinMartinov commented 1 month ago

@joeduffy thanks for pointing it out. I had left the template questions along with my repro steps, making it a bit hard to read. I've editted the upstream issue to leave only the relevant bits now.