Skip to content

Commit c335635

Browse files
committed
0.12.0 release; add docstring to aws_lambda.deploy_function and add examples dir
1 parent bd77732 commit c335635

5 files changed

Lines changed: 66 additions & 3 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include LICENSE
33
include README.rst
44
include requirements.txt
55
include python/boto/endpoints.json
6-
]recursive-include tests *.json *.py *.txt *.yaml
6+
recursive-include tests *.json *.py *.txt *.yaml
77
recursive-include templates *
88
recursive-exclude * __pycache__
99
recursive-exclude * *.py[co]

aws_lambda/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Version information."""
22

33
# The following line *must* be the last in the module, exactly as formatted:
4-
__version__ = "0.12.0-beta6"
4+
__version__ = "0.12.0"

aws_lambda/aws_lambda.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
log = logging.getLogger(__name__)
15-
log.setLevel(logging.INFO)
1615

1716

1817
def read_file(path, loader=None, binary_file=False):
@@ -25,6 +24,39 @@ def read_file(path, loader=None, binary_file=False):
2524

2625
def deploy_function(function_module, function_name_suffix='', package_objects=None,
2726
requirements_fpath=None, extra_config=None, local_package=None):
27+
"""
28+
Creates or updates a lambda function given a `function_module` that is a
29+
python module containing a dictionary config and correct handler function.
30+
The name of the handler function must match the `function_handler` value
31+
in the config.
32+
33+
Overall, this function creates a temporary directory and installs the lambda
34+
service function, as well as supplied python modules and pip packages. This
35+
directory is compressed as a temporary zip file and used to create/update
36+
the lambda function.
37+
38+
Args:
39+
function_module (types.ModuleType):
40+
Python module containing the `config` dictionary and handler
41+
function necessary to deploy the lambda function. See an examples
42+
in aws_lambda.examples.
43+
function_name_suffix (str):
44+
If provided, will append the given string (with prepended "_" if
45+
not present) to the deployed lambda function name.
46+
package_objects (list):
47+
Optional list of Python packages (types.ModuleType) that will be
48+
explicitly added to the zipfile for lambda code. Use this argument
49+
as an alternative to pip installing packages.
50+
requirements_fpath (str): path to requirements.txt file to pip install.
51+
extra_config (dict):
52+
additional kwargs that will be passed to boto3 create_function
53+
or update_function_configuration for lambda client. Optionally use
54+
to override `Environment` or any other arguments.
55+
local_package (str): optional path to a Python repo to pip install.
56+
57+
Returns:
58+
None
59+
"""
2860
# check provided function module and packages
2961
cfg = function_module.config
3062
function_fpath = function_module.__file__

aws_lambda/examples/__init__.py

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Example lambda configuation file, including `config` dictionary and
3+
an example handler function.
4+
5+
Would deploy with:
6+
```
7+
from aws_lambda import deploy_function
8+
from aws_lambda.examples import example_function
9+
deploy_function(example_function,
10+
function_name_suffix=<optional str suffix>,
11+
package_objects=<optional list of Python modules>,
12+
requirements_fpath=<optional path to requirements file>,
13+
extra_config=<optional dict for extra boto3 lambda kwargs>)
14+
```
15+
"""
16+
17+
18+
config = {
19+
'function_name': 'my_test_function',
20+
'function_module': 'service',
21+
'function_handler': 'handler',
22+
'handler': 'service.handler',
23+
'region': 'us-east-1',
24+
'runtime': 'python3.6',
25+
'role': 'my_iam_role',
26+
'description': 'Some description for my test lambda'
27+
}
28+
29+
30+
def handler(event, context):
31+
return 'Hello! My input event is %s' % event

0 commit comments

Comments
 (0)