Lambada Reference API Documentation¶
Lambada package entry point
-
class
lambada.
Bouncer
(config_file=None, env_prefix=u'BOUNCER_')[source]¶ Bases:
object
Configuration class for lambda type deployments where you don’t want to keep security information in source control, but don’t have environment variable configuration as a feature of Lambda. It pairs with the command line interface to package and serializes the current configuration into the zip file when packaging. This allows changing with local environment variable changes or different configuration file paths at package time).
Configuration files, if not specified, are loaded in the following order, with the first one found being the only configuration (they do not layer):
- Path specified by
BOUNCER_CONFIG
environment variable. lambada.yml
in the current working directory..lambada.yml
in yourHOME
directory/etc/lambada.yml
That said no configuration file is required and any environment variable with a certain prefix will be added to the attributes of this class when instantiated. The default is
BOUNCER_
so the environment variableBOUNCER_THING
will be set in the object asbouncer.thing
after construction.These prefixed environment variables will also override whatever value is in the config, so if your config file has a
thing
variable in it, andBOUNCER_THING
is set, the value of the environment variable will override the configuration file.Finds and sets up configuration by yaml file
Parameters: - config_file (str) – Path to configuration file
- env_prefix (str) – Prefix of environment variables to use as configuration
- Path specified by
-
class
lambada.
Dancer
(function, name=None, description=u'', **kwargs)[source]¶ Bases:
object
Simple function wrapping class to add context to the function (i.e. name, description, memory.)
Creates a dancer object to let us know something has been decorated and store the function as the callable.
Parameters: - function (callable) – Function to wrap.
- name (str) – Name of function.
- description (str) – Description of function.
- kwargs – See
OPTIONAL_CONFIG
for options, if not specified in dancer, the Lambada objects configuration is used, and if that is unspecified, the defaults listed there are used.
-
config
¶ A dictionary of configuration variables that can be merged in with the Lambada object
-
class
lambada.
Lambada
(handler=u'lambda.tune', bouncer=<lambada.Bouncer object>, **kwargs)[source]¶ Bases:
object
Lambada class for managing, discovery and calling the correct lambda dancers.
Setup the data structure of dancers and do some auto configuration for us with deploying to AWS using
lambda_uploader
. SeeOPTIONAL_CONFIG
for arguments and defaults.-
dancer
(name=None, description=u'', **kwargs)[source]¶ Wrapper that adds a given function to the dancers dictionary to be called.
Parameters: - name (str) – Optional lambda function name (default uses the name of the function decorated.
- description (str) – Description field in AWS of the function.
- kwargs – Key/Value overrides of either defaults or Lambada class
configuration values. See
OPTIONAL_CONFIG
for available options.
Returns: - Object with configuration and callable that is the function
being wrapped
Return type:
-
-
lambada.
get_config_from_env
(env_prefix=u'BOUNCER_')[source]¶ Get any and all environment variables with given prefix, remove prefix, lower case the name, and add as a dictionary item that is returned.
Parameters: env_prefix (str) – environemnt variable prefix. Returns: - empty if no environment variables were found, or the
- dictionary of found variables that match the prefix.
Return type: dict
-
lambada.
get_config_from_file
(config_file=None)[source]¶ Finds configuration file and returns the python object in it or raises on parsing failures.
Parameters: config_file (str) – Optional path to configuration file, runs through CONFIG_PATHS
if none is specified.Raises: yaml.YAMLError
Returns: - empty if no configuration file was found, or the
- contents of that file.
Return type: dict
lambada.cli module¶
Command line interface for running, packaging, and uploading commands to AWS.
lambada.common module¶
Common classes, functions, etc.
-
class
lambada.common.
LambadaConfig
(path, config)[source]¶ Bases:
lambda_uploader.config.Config
Small override to load config from dictionary instead of from a configuration file.
Takes config dictionary directly instead of retrieving it from a configuration file.
-
class
lambada.common.
LambdaContext
(function_name, function_version=None, invoked_function_arn=None, memory_limit_in_mb=None, aws_request_id=None, log_group_name=None, log_stream_name=None, identity=None, client_context=None, timeout=None)[source]¶ Bases:
object
Convenient class duplication of the one passed in by Amazon as defined at:
http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html
Setup all the attributes of the class.