RJPearson94 / terraform-provider-twilio

Terraform Twilio provider
https://registry.terraform.io/providers/RJPearson94/twilio/latest/docs
Mozilla Public License 2.0
32 stars 7 forks source link

Twilio Rate limit reached #39

Closed thomaschaaf closed 3 years ago

thomaschaaf commented 3 years ago

Technical Details

Affected Resources

all if there are too many resources

Describe the bug

Error: Failed to create workflow: Rate limit exceeded for target Workflow-Create

This is caused by the 1 request per second rate limit: https://stackoverflow.com/questions/68637366/rate-limit-exceeded-for-target-task-list-evaluatetaskattributes#comment121322707_68644314

Steps to Reproduce

Steps to reproduce the behaviour:

  1. Create a lot of resources (multiple times)
  2. See error

Expected behaviour

Should retry if rate limit error is caught.

RJPearson94 commented 3 years ago

Hi @thomaschaaf,

Thanks for reaching out and apologies for the issues you are seeing.

The Go SDK that is been used the hood by the provider, is already retrying with exponential backoff when rate-limiting occurs from the Twilio API.

The Terraform provider is currently using the SDK default configuration of 3 retries with a backoff of 5 seconds, as seen here. So from the issue, you are seeing this configuration isn't suitable for your use case

As the default configuration can be overridden I can look at enhancing the provider to add 2 new attributes to allow both the number of retries and wait time to be configured for the provider, this should allow you to work around this issue.

RJPearson94 commented 3 years ago

Hi @thomaschaaf,

I have updated the provider to support configuring the number of retries and the backoff interval for the provider. 2 new attributes (retry_attempts & backoff_interval_in_ms have been added to the provider which are documented here

The new attributes have been released as part of v0.16.0 which is now available in the Terraform Registry.

Please update your Terraform configuration to include the following

terraform {
  required_providers {
    twilio = {
      source = "RJPearson94/twilio"
      version = ">= 0.16.0"
    }
  }
}

I believe these new attributes should help you workaround the rate limiting issue you are experiencing.

Are you able to update your Terraform code to include these new attributes to see if this resolves your issue?

RJPearson94 commented 3 years ago

HI @thomaschaaf, did you manage to try out the new attributes? Did it help mitigate the rate-limiting issues that you saw?

thomaschaaf commented 3 years ago

Thank you! I think everything works now :)

RJPearson94 commented 3 years ago

Thanks for trying this out. I’m going to close this issue. Feel free to reopen it if the issue reoccurs