Menu

Expand
Rate this page:

Deploying with the Serverless Toolkit

This is a Twilio Labs project

This means this project is 100% open-source. You can find its source code in the Twilio Labs GitHub organization.

We currently don't support the projects through our official support channels. But you are welcome to reach out to us on GitHub for any questions, issues or suggestions or to contribute to this project.

Learn more about Twilio Labs.

There are two ways you can use the toolkit. If you are already using the Twilio CLI, you can install it via a plugin. Alternatively, you can use the toolkit as a standalone using twilio-run via npm or another Node.js package manager.

Throughout the docs we'll reference the Twilio CLI commands.

The Serverless Toolkit will perform a collection of API requests on your behalf and in order to speed things up might do so in parallel. Depending on your account it might get into the situation where you hit issues deploying due to concurrency issues.

To solve this issue, you can set the environment variable TWILIO_SERVERLESS_API_CONCURRENCY to a value such as 1 to avoid any requests being performed in parallel.

Deploying new code

The Serverless Toolkit tries to make deploying as seamless and with as little configuration as possible. If you have a project set-up according to the Serverless project structure, all it takes to deploy is one short command.

        
        
        
        

        By default this will create a new environment for you with the following properties:

        • Domain Suffix: dev
        • Unique Name: dev-environment

        You can change the environment it deploys to by passing the domain suffix of the environment into the deploy command using the --environment flag. If an environment with that domain suffix already exists, it will deploy to that one, otherwise it will create a new one.

              
              
              
              

              If you don't pass any other options in, the Functions and Assets that are being deployed will be chosen based on your project structure. If you use a non-default folder name for the deployment of Assets or Functions, you can pass in the --assets-folder or --functions-folder flags to change them. Alternatively you can use the --no-assets and --no-functions flags to turn these features of completely.

                    
                    
                    
                    

                    Additionally any variables except ACCOUNT_SID and AUTH_TOKEN will be uploaded as part of your deployment. To change the variables that are being uploaded use the --env flag to point against another .env file.

                          
                          
                          
                          

                          There's a lot more configuration you can do for your deployment. The best way you can find out about the various options is using the --help flag. It will list all options you have available.

                          Replicating an existing deployment

                          Aside of deploying code to an environment by uploading everything again, you can take an existing deployment and activate it on another environment using the promote command. For example to move the same build from the dev environment to an environment with the domain suffix staging you can use the activate command.

                                
                                
                                
                                

                                What's next?

                                Now that you learned how you can deploy your Twilio Functions, why not learn more, like how you can locally develop and debug your Functions.

                                Rate this page:

                                Need some help?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

                                      
                                      
                                      

                                      Thank you for your feedback!

                                      We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      Refer us and get $10 in 3 simple steps!

                                      Step 1

                                      Get link

                                      Get a free personal referral link here

                                      Step 2

                                      Give $10

                                      Your user signs up and upgrade using link

                                      Step 3

                                      Get $10

                                      1,250 free SMSes
                                      OR 1,000 free voice mins
                                      OR 12,000 chats
                                      OR more