twilio / terraform-provider-twilio

Terraform Twilio provider
MIT License
62 stars 13 forks source link

IP Access Control Lists do not support /0 "wildcard" CIDRs #137

Open WestonReed opened 5 months ago

WestonReed commented 5 months ago

Issue Summary

This may be more of an issue with the Twilio API than the Terraform provider directly, but if so, the provider does not correctly handle cidr_prefix_length = 0 during plans. The API appears to overwrite this with a /32, which then leads to drift on every run.

Steps to Reproduce

  1. Use the below code snippet to create a couple of resources in the Twilio console.
  2. The apply will run successfully, but the Twilio console will show that the below access control list was created as 0.0.0.0/32; not the expected 0.0.0.0/0.
  3. Subsequent plans now show that cidr_prefix_length drifts, and Terraform is never able to correct this.

Code Snippet

resource "twilio_api_accounts_sip_ip_access_control_lists" "twilio_acl" {
  friendly_name    = "All (0.0.0.0/0)"
}

resource "twilio_api_accounts_sip_ip_access_control_lists_ip_addresses" "twilio_acl_all" {
  ip_access_control_list_sid = twilio_api_accounts_sip_ip_access_control_lists.twilio_acl.sid
  friendly_name              = "All (0.0.0.0/0)"
  ip_address                 = "0.0.0.0"
  cidr_prefix_length         = 0
}

Technical details:

Workaround

As a workaround, creating two access control lists with prefixes of 0.0.0.0/1 and 128.0.0.0/1 respectively works, however this is confusing.

Expected Behavior

Either: A. The API should support wildcards (0.0.0.0/0) and thus the above code works as expected (preferred) B. The Terraform provider should fail validation on the above code because the API does not support /0s and the API should return a 4XX to indicate that it isn't supported.