Given a Serverless Context
object, finds and returns the first available EnvironmentInstance
.
Note that if running on localhost
, or if no EnvironmentInstance
s are available, this function
returns undefined
.
Usage: const environment = await getCurrentEnvironment(context);
The current Serverless context.
The first valid environment for the given context, or undefined
.
Given a Serverless Context
, an EnvironmentInstance
(usually from
getCurrentEnvironment), and a string key
, returns the environment
variable corresponding to key
, or undefined
if no matching variable
exists.
Usage: const var = await getEnvironmentVariable(context, environment, 'var');
The current Serverless context.
A Serverless environment.
The name of the environment variable to access.
The VariableInstance
matching the key
, or undefined
if no match is found.
Given a Serverless Context
and an EnvironmentInstance
(usually from getCurrentEnvironment),
returns a list of defined environment variable instances.
Usage: const envVars = await getEnvironmentVariables(context, environment);
The current Serverless context.
A Serverless environment.
A list of environment variable instances.
For a given Serverless Context
and EnvironmentInstance
, set the environment variable
named key
to value
.
If the override
parameter is true
(the default), setting an existing environment variable
will override its current value with the new one. If it is false
, then this function will instead
log a warning and return false
.
Usage: setEnvironmentVariable(context, envrionment, 'var', 'value');
The current Serverless context.
A Serverless environment.
The name of the environment variable to set.
The value to store in the environment variable.
If true, allow overriding existing variables.
true
if setting the environment variable succeeded, false
if an error occurred
Generated using TypeDoc
A set of utilities for accessing and modifying environment variables in Twilio Functions.