Develop and deploy Twilio Serverless Functions
npm install @twilio-labs/plugin-serverlessPlugin for the Twilio CLI to locally develop, debug and deploy to Twilio Serverless. Part of the Serverless Toolkit
This plugin adds functionality to the Twilio CLI to locally develop,
debug and deploy to Twilio Serverless. It's a part of the Serverless Toolkit and wraps twilio-run and create-twilio-function.
> Important: This version requires Twilio CLI version 3.0 or newer. For Twilio CLI version 2.x you have to use plugin-serverless version 2.4.
Via npm or yarn:
``sh-session`
$ npm install -g twilio-cli
$ yarn global add twilio-cli
Via homebrew:
`sh-session`
$ brew tap twilio/brew && brew install twilio
`sh-session`
$ twilio plugins:install @twilio-labs/plugin-serverless
$ twilio --help serverless
USAGE
$ twilio serverless
...
When deploying lots of Functions and Assets it is possible to run up against the enforced concurrency limits of the Twilio API. You can limit the concurrency and set how many times the library retries API requests using environment variables.
It is advisable to keep the concurrency low (around 10-15) to avoid hitting the rate limits of the Twilio API.
The default concurrency is 10 and the default number of retries is 10. You can change this by setting environment variables. The following would set concurrency to 1, only 1 live request at a time, and retries to 0, so if it fails it won't retry.
`sh-session`
export TWILIO_SERVERLESS_API_CONCURRENCY=1
export TWILIO_SERVERLESS_API_RETRY_LIMIT=0
* twilio serverless:activate
* twilio serverless:deploy
* [twilio serverless:dev [DIR]](#twilio-serverlessdev-dir)twilio serverless:env:get
* twilio serverless:env:import
* twilio serverless:env:list
* twilio serverless:env:set
* twilio serverless:env:unset
* twilio serverless:init NAME
* twilio serverless:list [TYPES]
* [](#twilio-serverlesslist-types)twilio serverless:list-templates
* twilio serverless:logs
* twilio serverless:new [NAMESPACE]
* [](#twilio-serverlessnew-namespace)twilio serverless:promote
* twilio serverless:run [DIR]
* [](#twilio-serverlessrun-dir)twilio serverless:start [DIR]
* [](#twilio-serverlessstart-dir)
Promotes an existing deployment to a new environment
`
USAGE
$ twilio serverless:activate [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
[--environment
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-o, --output-format=
-p, --profile=
-u, --username=
otherwise
--build-sid=
--create-environment Creates environment if it couldn't find it.
--cwd=
directory
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--force Will run deployment in force mode. Can be dangerous.
--from=
--from-build=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides
environment flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--source-environment=
--to=
DESCRIPTION
Promotes an existing deployment to a new environment
ALIASES
$ twilio serverless:activate
`
Deploys existing functions and assets to Twilio
`
USAGE
$ twilio serverless:deploy [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
[--functions] [--assets] [--assets-folder
[--production]
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-n, --service-name=
package.json
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-o, --output-format=
-p, --profile=
-u, --username=
otherwise
--[no-]assets Upload assets. Can be turned off with --no-assets
--assets-folder=
--cwd=
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--force Will run deployment in force mode. Can be dangerous.
--[no-]functions Upload functions. Can be turned off with --no-functions
--functions-folder=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--override-existing-project Deploys Serverless project to existing service if a naming conflict has been found.
--password=
--production Please prefer the "activate" command! Deploys to the production environment (no
domain suffix). Overrides the value passed via the environment flag.
--runtime=
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
DESCRIPTION
Deploys existing functions and assets to Twilio
`
_See code: src/commands/serverless/deploy.js_
Starts local Twilio Functions development server
`
USAGE
$ twilio serverless:dev [DIR] -p
[--assets-folder
ARGUMENTS
[DIR] Root directory to serve local Functions/Assets from
FLAGS
-c, --config=
(cwd)
-f, --load-local-env Includes the local environment variables
-l, --log-level=
-p, --port=
--assets-folder=
--cwd=
argument passed.
--detailed-logs Toggles detailed request logging by showing request body and query params
--env=
--[no-]fork-process Disable forking function processes to emulate production environment
--functions-folder=
--inspect=
--inspect-brk=
--legacy-mode Enables legacy mode, it will prefix your asset paths with /assets
--[no-]live Always serve from the current functions (no caching)
--[no-]logs Toggles request logging
--ngrok=
paid-for ngrok account).
DESCRIPTION
Starts local Twilio Functions development server
ALIASES
$ twilio serverless:dev
$ twilio serverless:run
`
Retrieves the value of a specific environment variable
`
USAGE
$ twilio serverless:env:get [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--key=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides environment
flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
DESCRIPTION
Retrieves the value of a specific environment variable
`
_See code: src/commands/serverless/env/get.js_
Takes a .env file and uploads all environment variables to a given environment
`
USAGE
$ twilio serverless:env:import [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides environment
flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
DESCRIPTION
Takes a .env file and uploads all environment variables to a given environment
`
_See code: src/commands/serverless/env/import.js_
Lists all environment variables for a given environment
`
USAGE
$ twilio serverless:env:list [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-o, --output-format=
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides environment
flag
--service-sid=
--show-values Show the values of your environment variables
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
DESCRIPTION
Lists all environment variables for a given environment
`
_See code: src/commands/serverless/env/list.js_
Sets an environment variable with a given key and value
`
USAGE
$ twilio serverless:env:set [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--key=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides environment
flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
--value=
DESCRIPTION
Sets an environment variable with a given key and value
`
_See code: src/commands/serverless/env/set.js_
Removes an environment variable for a given key
`
USAGE
$ twilio serverless:env:unset [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--key=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides environment
flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
DESCRIPTION
Removes an environment variable for a given key
`
_See code: src/commands/serverless/env/unset.js_
Creates a new Twilio Function project
`
USAGE
$ twilio serverless:init NAME [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--typescript]
ARGUMENTS
NAME Name of Serverless project and directory that will be created
FLAGS
-a, --account-sid=
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-p, --profile=
-t, --auth-token=
--empty Initialize your new project with empty functions and assets directories
--import-credentials Import credentials from the environment variables TWILIO_ACCOUNT_SID and
TWILIO_AUTH_TOKEN
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--skip-credentials Don't ask for Twilio account credentials or import them from the environment
--template=
github.com/twilio-labs/function-templates
--typescript Initialize your Serverless project with TypeScript
DESCRIPTION
Creates a new Twilio Function project
`
_See code: src/commands/serverless/init.js_
List existing services, environments, variables, deployments for your Twilio Serverless Account
`
USAGE
$ twilio serverless:list [TYPES] [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--load-system-env] [-n
[--to
ARGUMENTS
[TYPES] [default: services] Comma separated list of things to list (services,environments,functions,assets,variables)
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-n, --service-name=
package.json
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-o, --output-format=
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
--extended-output Show an extended set of properties on the output
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--to=
DESCRIPTION
List existing services, environments, variables, deployments for your Twilio Serverless Account
`
_See code: src/commands/serverless/list.js_
Lists the available Twilio Function templates
`
USAGE
$ twilio serverless:list-templates [-o
FLAGS
-o, --output-format=
DESCRIPTION
Lists the available Twilio Function templates
`
_See code: src/commands/serverless/list-templates.js_
Print logs from your Twilio Serverless project
`
USAGE
$ twilio serverless:logs [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-o, --output-format=
-p, --profile=
-u, --username=
otherwise
--cwd=
--env=
--environment=
--function-sid=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Retrieve logs for the production environment. Overrides the "environment" flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--tail Continuously stream the logs
--to=
DESCRIPTION
Print logs from your Twilio Serverless project
`
_See code: src/commands/serverless/logs.js_
Creates a new Twilio Function based on an existing template
`
USAGE
$ twilio serverless:new [NAMESPACE] [-l
ARGUMENTS
[NAMESPACE] The namespace your assets/functions should be grouped under
FLAGS
-c, --config=
-l, --log-level=
--cwd=
--env=
--template=
DESCRIPTION
Creates a new Twilio Function based on an existing template
`
_See code: src/commands/serverless/new.js_
Promotes an existing deployment to a new environment
`
USAGE
$ twilio serverless:promote [-l (debug|info|warn|error|none)] [-o (columns|json|tsv|none)] [--silent] [-p
[--service-sid
[--environment
FLAGS
-c, --config=
(cwd)
-l=(debug|info|warn|error|none) [default: info] Level of logging messages.
-l, --log-level=
-o=(columns|json|tsv|none) [default: columns] Format of command output.
-o, --output-format=
-p, --profile=
-u, --username=
otherwise
--build-sid=
--create-environment Creates environment if it couldn't find it.
--cwd=
directory
--env=
--environment=
deployment. Alternatively you can specify an environment SID starting with ZE.
--force Will run deployment in force mode. Can be dangerous.
--from=
--from-build=
--load-system-env Uses system environment variables as fallback for variables specified in your .env
file. Needs to be used with --env explicitly specified.
--password=
--production Promote build to the production environment (no domain suffix). Overrides
environment flag
--service-sid=
--silent Suppress output and logs. This is a shorthand for "-l none -o none".
--source-environment=
--to=
DESCRIPTION
Promotes an existing deployment to a new environment
ALIASES
$ twilio serverless:activate
`
_See code: src/commands/serverless/promote.js_
Starts local Twilio Functions development server
`
USAGE
$ twilio serverless:run [DIR] -p
[--assets-folder
ARGUMENTS
[DIR] Root directory to serve local Functions/Assets from
FLAGS
-c, --config=
(cwd)
-f, --load-local-env Includes the local environment variables
-l, --log-level=
-p, --port=
--assets-folder=
--cwd=
argument passed.
--detailed-logs Toggles detailed request logging by showing request body and query params
--env=
--[no-]fork-process Disable forking function processes to emulate production environment
--functions-folder=
--inspect=
--inspect-brk=
--legacy-mode Enables legacy mode, it will prefix your asset paths with /assets
--[no-]live Always serve from the current functions (no caching)
--[no-]logs Toggles request logging
--ngrok=
paid-for ngrok account).
DESCRIPTION
Starts local Twilio Functions development server
ALIASES
$ twilio serverless:dev
$ twilio serverless:run
`
Starts local Twilio Functions development server
`
USAGE
$ twilio serverless:start [DIR] -p
[--assets-folder
ARGUMENTS
[DIR] Root directory to serve local Functions/Assets from
FLAGS
-c, --config=
(cwd)
-f, --load-local-env Includes the local environment variables
-l, --log-level=
-p, --port=
--assets-folder=
--cwd=
argument passed.
--detailed-logs Toggles detailed request logging by showing request body and query params
--env=
--[no-]fork-process Disable forking function processes to emulate production environment
--functions-folder=
--inspect=
--inspect-brk=
--legacy-mode Enables legacy mode, it will prefix your asset paths with /assets
--[no-]live Always serve from the current functions (no caching)
--[no-]logs Toggles request logging
--ngrok=
paid-for ngrok account).
DESCRIPTION
Starts local Twilio Functions development server
ALIASES
$ twilio serverless:dev
$ twilio serverless:run
`
_See code: src/commands/serverless/start.js_
This project welcomes contributions from the community. Please see the CONTRIBUTING.md` file for more details.
Please be aware that this project has a Code of Conduct. The tldr; is to just be excellent to each other ❤️
Thanks goes to these wonderful people (emoji key):
Dominik Kundel 💻 📖 🤔 | childish-sambino 💻 🐛 | Elmer Thomas 🐛 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT