twilio / terraform-provider-twilio

Terraform Twilio provider
MIT License
63 stars 13 forks source link

Twilio TaskRouter TaskChannel resource cannot be updated #128

Open vinitdave27 opened 1 year ago

vinitdave27 commented 1 year ago

Issue Summary

I am able to import the Twilio TaskRouter TaskChannel resource into my terraform state, but when attempting to update the "channel_optimized_routing" parameter for any imported(already existing) TaskChannel resource, the terraform apply fails. SCR-20230417-ssw

On further investigation, It seems for the TaskRouter TaskChannel Resource REST API, “FriendlyName” parameters is optional and there is no way to update the “UniqueName” using the REST API.

Although, when using the terraform provider, the schema defined for the TaskChannel resource states that “friendly_name” is mandatory/required represented with “SchemaRequired” and “unique_name” is not only mandatory/required but is also marked as “ForceNew” represented with “SchemaForceNewRequired”. According to Terraform docs, ForceNew indicates that any change in this field requires the resource to be destroyed and recreated. SCR-20230418-d7c

The terraform-provider-twilio requires us to pass the unique_name because it is mandatory, but the Twilio TaskRouter backend throws an error doing the update as TaskRouter does not allow us to update the unique_name/UniqueName of the TaskChannel once created.

Steps to Reproduce

  1. Import any Twilio TaskRouter TaskChannel into your state.
  2. Update the TaskChannel resource you imported to change the "channel_optimized_routing" parameter from false --> true.
  3. Perform a terraform apply

Code Snippet

resource "twilio_taskrouter_workspaces_task_channels_v1" "voice" {
  friendly_name             = "Voice"
  unique_name               = "voice"
  channel_optimized_routing = true
  workspace_sid             = var.workspace_sid
}

Exception/Log

SCR-20230417-ssw

Technical details: