Objective
When working with Twilio Functions and Assets, you may encounter situations where you need to revert your deployment to a previous build. This is especially useful if a recent deployment introduced issues or if you need to restore a known good state. The Twilio CLI, together with the Serverless Toolkit plugin, provides a straightforward way to promote a previous build to be the active deployment for your environment.
Product
Twilio Functions
Procedure
Prerequisites
- Twilio Account: You must have a Twilio account
- Twilio CLI Installed: Install the Twilio CLI
- Serverless Toolkit Plugin Installed: Install the Serverless Plugin using Twilio CLI
- CLI Authentication: Ensure you are logged in to the Twilio CLI with the correct credentials.
- Service, Environment, and Build SIDs: You will need to identify the correct Service SID, Environment SID, and Build SID for your deployment. These can be found using the CLI commands below.
Important Notes
- Builds will be deleted 7 days after not being associated to an active deployment
- Promoting a previous build will restore all functions and assets to the state they were in at the time of that build.
Step-by-Step Process
Get your Service SID
twilio serverless:list servicesGet your Environment SID
twilio serverless:list environments \
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXGet your Build SID
twilio api:serverless:v1:services:builds:list \
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--limit 20Promote an Old Build
twilio serverless:promote \
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--environment-sid ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--build-sid ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXVerify active build for the environment
twilio serverless:list environments \
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXTroubleshooting & Best Practices
- To verify you are promoting the correct build by review the build’s creation date and contents.
twilio api:serverless:v1:services:builds:fetch \
--service-sid ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--sid ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \- Keep your CLI and plugins up to date to avoid compatibility issues.