twilio / terraform-provider-twilio

Terraform Twilio provider
MIT License
62 stars 13 forks source link

Removing EventSink event type not picked up #84

Closed petehannam closed 2 years ago

petehannam commented 2 years ago

Issue Summary

Removing an event sink subscription event type is not reflected in the Twilio console.

Steps to Reproduce

I configured an event sink subscription to publish for two event types:

resource "twilio_events_subscriptions_v1" "cloudflare_events_taskrouter_worker" {
  description = "Event types sent to Cloudflare - Worker"
  sink_sid    = twilio_events_sinks_v1.cloudflare_taskrouter_worker.sid
  types = [
    jsonencode({ type = "com.twilio.taskrouter.worker.activity.update" }),
    jsonencode({ type = "com.twilio.taskrouter.worker.channel.availability.update" }),
  ]
}

I then removed one of the event types:

resource "twilio_events_subscriptions_v1" "cloudflare_events_taskrouter_worker" {
  description = "Event types sent to Cloudflare - Worker"
  sink_sid    = twilio_events_sinks_v1.cloudflare_taskrouter_worker.sid
  types = [
    jsonencode({ type = "com.twilio.taskrouter.worker.activity.update" }),
  ]
}

Terraform detected the change:

  # twilio_events_subscriptions_v1.cloudflare_events_taskrouter_worker will be updated in-place
  ~ resource "twilio_events_subscriptions_v1" "cloudflare_events_taskrouter_worker" {
        id          = "DFdb9185c428d84a3f04c97d14edf8f298"
      ~ types       = [
            jsonencode(
                {
                    type = "com.twilio.taskrouter.worker.activity.update"
                }
            ),
          - jsonencode(
                {
                  - type = "com.twilio.taskrouter.worker.channel.availability.update"
                }
            ),
        ]
        # (3 unchanged attributes hidden)
    }

Expected: Event type is removed from subscription Actual: Event type is not removed from subscription

Work around: Manually remove event type from subscription via Twilio console

Technical details:

eshanholtz commented 2 years ago

Hi @petehannam , The short answer to why this isn't working is that the Subscription API endpoint update action does not actually support modifying the types list in this way. What is likely happening when you remove the event type in the console is that it's using the Subscribed Events API delete endpoint, which results in the associated subscription being "updated" indirectly. It does make sense to me, though, that the Subscription API endpoint should be able to update the types list in this manner. I've reached out to the related product team regarding this issue.