Skip to content

Commit 41772c5

Browse files
committed
Initial commit
0 parents  commit 41772c5

8 files changed

Lines changed: 744 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
.idea
3+
.venv
4+
*.egg-info

LICENSE.txt

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
1. Create a virtual environment:
2+
3+
`$ python3 -m venv .venv`
4+
5+
2. Activate the created environment:
6+
7+
`$ source .venv/bin/activate`
8+
9+
3. Upgrade `pip`:
10+
11+
`$ python3 -m pip install --upgrade pip`
12+
13+
4. Install the requirements:
14+
15+
`$ pip install --upgrade -r requirements.txt`

lambda_utils/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import boto3
2+
import json
3+
4+
from typing import Dict, Any, AnyStr
5+
6+
7+
def invoke_lambda(payload: Dict[AnyStr, Any], lambda_name: AnyStr) -> bool:
8+
"""Invokes a Lambda asynchronously with a payload
9+
10+
Data must be serializable.
11+
12+
:param payload: Data to send
13+
:param lambda_name: Name of the Lambda to invoke
14+
:return: True if data was sent
15+
"""
16+
17+
status_code = boto3.client('lambda').invoke(
18+
FunctionName=lambda_name,
19+
InvocationType='Event',
20+
Payload=json.dumps(payload).encode('utf-8')
21+
).get('StatusCode')
22+
23+
return 200 <= status_code <= 208

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-e .

setup.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
import setuptools
3+
4+
from typing import AnyStr
5+
6+
7+
GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')
8+
9+
10+
def private_dependency(personal_access_token: AnyStr,
11+
repo_user: AnyStr, repo_name: AnyStr,
12+
package_name: AnyStr, package_version: AnyStr):
13+
"""Defines a dependency from a private Github repository
14+
15+
:param personal_access_token: Github Personal Access Token
16+
:param repo_user: Dependency repository user
17+
:param repo_name: Dependency repository name
18+
:param package_name: Dependency package name
19+
:param package_version: Dependency repository release (tag)
20+
:return: The dependency specification for the install_requires field
21+
"""
22+
23+
return f'{package_name} @ ' \
24+
f'git+https://{personal_access_token}@github.com/' \
25+
f'{repo_user}/{repo_name}.git/@{package_version}#egg={package_name}-0'
26+
27+
28+
with open('version', 'r') as version:
29+
30+
setuptools.setup(
31+
name='lambda_utils',
32+
version=version.readline(),
33+
author='Alessio Vierti',
34+
packages=setuptools.find_packages(exclude=['tests']),
35+
install_requires=[
36+
'boto3==1.16.53'
37+
],
38+
python_requires='>=3.6'
39+
)

tests/__init__.py

Whitespace-only changes.

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)